Skip to content

Commit

Permalink
fix(storybook): fix package.json, use module.hot api (#4937)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng committed Nov 14, 2023
1 parent 2555586 commit a23bd89
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changeset/mighty-mice-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/storybook': patch
'@modern-js/storybook-builder': patch
---

fix(storybook): package json types and use module.hot instead of import.meta.hot
fix(storybook): 修改 package json types 字段以及改用 module.hot 而不是 import.meta.hot
6 changes: 3 additions & 3 deletions packages/storybook/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
],
"exports": {
".": {
"jsnext:source": "./src/index.ts",
"types": "./dist/types/index.d.ts",
"jsnext:source": "./src/index.ts",
"default": "./dist/cjs/index.js"
},
"./preset": "./dist/esm/preset.js",
"./addons": {
"jsnext:source": "./src/addons/preset/preview.ts",
"types": "./dist/types/addons/preset/preview.d.ts",
"jsnext:source": "./src/addons/preset/preview.ts",
"default": "./dist/esm/addons/preset/preview.js"
},
"./types": {
"jsnext:source": "./src/types.ts",
"types": "./dist/types/types.d.ts",
"jsnext:source": "./src/types.ts",
"default": "./dist/cjs/types.js"
},
"./templates/preview.ejs": "./templates/preview.ejs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore

preview.initialize({ importFn, getProjectAnnotations });

if (import.meta.webpackHot) {
import.meta.webpackHot.accept('./{{storiesFilename}}', () => {
if (module.hot) {
module.hot.accept('./{{storiesFilename}}', () => {
// importFn has changed so we need to patch the new one in
preview.onStoriesChanged({ importFn });
});

import.meta.webpackHot.accept([
module.hot.accept([
{{#each previewAnnotations}}'{{this}}',
{{/each}}
], () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/storybook/framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@
},
"exports": {
".": {
"jsnext:source": "./src/index.ts",
"types": "./dist/index.d.ts",
"jsnext:source": "./src/index.ts",
"default": "./dist/index.js"
},
"./addons": {
"jsnext:source": "./src/addons.ts",
"types": "./dist/addons.d.ts",
"jsnext:source": "./src/addons.ts",
"default": "./dist/addons.js"
},
"./preset": {
"jsnext:source": "./src/preset.ts",
"types": "./dist/preset.d.ts",
"jsnext:source": "./src/preset.ts",
"default": "./dist/preset.js"
},
"./types": {
"jsnext:source": "./src/types.ts",
"types": "./dist/types.d.ts",
"jsnext:source": "./src/types.ts",
"default": "./dist/types.ks"
},
"./bin": "./bin.js",
Expand Down

0 comments on commit a23bd89

Please sign in to comment.