From 37dd381f97b2c0f38961fa668f82cb3bca56b8f8 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 29 Jun 2022 14:31:18 +0200 Subject: [PATCH] fixes --- lib/blocks/package.json | 23 +++++++++++++++---- lib/manager-webpack5/package.json | 1 + .../src/presets/manager-preset.ts | 11 +++++++++ package.json | 1 - scripts/build-manager-config/main.js | 5 ---- yarn.lock | 4 ++-- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/lib/blocks/package.json b/lib/blocks/package.json index 8d4ac34974da..efc037ac8bef 100644 --- a/lib/blocks/package.json +++ b/lib/blocks/package.json @@ -20,9 +20,17 @@ }, "license": "MIT", "sideEffects": false, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/types/index.d.ts", + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", "files": [ "dist/**/*", "README.md", @@ -30,7 +38,7 @@ "*.d.ts" ], "scripts": { - "prepare": "node ../../scripts/prepare.js" + "prepare": "esrun ../../scripts/prepare/bundle.ts" }, "dependencies": { "@mdx-js/react": "^1.6.22", @@ -53,10 +61,12 @@ "memoizerific": "^1.11.3", "polished": "^4.2.2", "react-colorful": "^5.1.2", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2" }, + "devDependencies": { + "@digitak/esrun": "^3.2.2" + }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" @@ -64,5 +74,8 @@ "publishConfig": { "access": "public" }, + "bundlerEntrypoint": [ + "./src/index.ts" + ], "gitHead": "b2e85f3599c043815b18bbfc5ca563bf1c6e4add" } diff --git a/lib/manager-webpack5/package.json b/lib/manager-webpack5/package.json index 4f5000f92afc..ce5a7bc3f70b 100644 --- a/lib/manager-webpack5/package.json +++ b/lib/manager-webpack5/package.json @@ -46,6 +46,7 @@ "@storybook/theming": "7.0.0-alpha.7", "@storybook/ui": "7.0.0-alpha.7", "@types/node": "^14.0.10 || ^16.0.0", + "assert": "^2.0.0", "babel-loader": "^8.2.5", "case-sensitive-paths-webpack-plugin": "^2.4.0", "chalk": "^4.1.0", diff --git a/lib/manager-webpack5/src/presets/manager-preset.ts b/lib/manager-webpack5/src/presets/manager-preset.ts index 16aace616e26..b03d68439702 100644 --- a/lib/manager-webpack5/src/presets/manager-preset.ts +++ b/lib/manager-webpack5/src/presets/manager-preset.ts @@ -116,6 +116,16 @@ export async function managerWebpack( ].filter(Boolean), module: { rules: [ + { + test: /\.m?js$/, + type: 'javascript/auto', + }, + { + test: /\.m?js$/, + resolve: { + fullySpecified: false, + }, + }, customManagerRuntimeLoader(), { test: /\.css$/, @@ -159,6 +169,7 @@ export async function managerWebpack( modules: ['node_modules'].concat(envs.NODE_PATH || []), mainFields: ['browser', 'module', 'main'].filter(Boolean), alias: uiPaths, + fallback: { assert: require.resolve('assert/') }, }, recordsPath: resolvePathInStorybookCache('public/records.json'), performance: { diff --git a/package.json b/package.json index 7002d9445a4b..e5a3312b5ebc 100644 --- a/package.json +++ b/package.json @@ -244,7 +244,6 @@ "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/experimental-utils": "^5.20.0", "@typescript-eslint/parser": "^5.15.0", - "assert": "^2.0.0", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.1.0", "babel-jest": "^26.6.3", diff --git a/scripts/build-manager-config/main.js b/scripts/build-manager-config/main.js index 59f4b043791d..876a78f26d61 100644 --- a/scripts/build-manager-config/main.js +++ b/scripts/build-manager-config/main.js @@ -5,9 +5,4 @@ module.exports = { builder: '@storybook/builder-webpack5', disableTelemetry: true, }, - managerWebpack: async (config) => { - // eslint-disable-next-line no-param-reassign - config.resolve.fallback = { assert: require.resolve('assert/') }; - return config; - }, }; diff --git a/yarn.lock b/yarn.lock index 50182cf9a563..cb2265db3f01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7780,6 +7780,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/blocks@workspace:lib/blocks" dependencies: + "@digitak/esrun": ^3.2.2 "@mdx-js/react": ^1.6.22 "@storybook/addons": 7.0.0-alpha.7 "@storybook/api": 7.0.0-alpha.7 @@ -7800,7 +7801,6 @@ __metadata: memoizerific: ^1.11.3 polished: ^4.2.2 react-colorful: ^5.1.2 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 peerDependencies: @@ -8727,6 +8727,7 @@ __metadata: "@types/terser-webpack-plugin": ^5.2.0 "@types/webpack-dev-middleware": ^5.3.0 "@types/webpack-virtual-modules": ^0.1.1 + assert: ^2.0.0 babel-loader: ^8.2.5 case-sensitive-paths-webpack-plugin: ^2.4.0 chalk: ^4.1.0 @@ -9323,7 +9324,6 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.15.0 "@typescript-eslint/experimental-utils": ^5.20.0 "@typescript-eslint/parser": ^5.15.0 - assert: ^2.0.0 babel-core: ^7.0.0-bridge.0 babel-eslint: ^10.1.0 babel-jest: ^26.6.3