Skip to content

Commit

Permalink
Merge pull request #18544 from storybookjs/future/tsup-presets-1
Browse files Browse the repository at this point in the history
Build: Use TSUP to compile the presets
  • Loading branch information
shilman authored Jun 29, 2022
2 parents ad680d1 + 4cc186b commit fcacaf7
Show file tree
Hide file tree
Showing 24 changed files with 310 additions and 60 deletions.
31 changes: 27 additions & 4 deletions presets/html-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,34 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"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"
},
"./preset": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/core-webpack": "7.0.0-alpha.6",
Expand All @@ -40,6 +57,9 @@
"react-dom": "16.14.0",
"webpack": "5"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2"
},
"peerDependencies": {
"@babel/core": "*"
},
Expand All @@ -49,5 +69,8 @@
"publishConfig": {
"access": "public"
},
"bundlerEntrypoint": [
"./src/index.ts"
],
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec"
}
2 changes: 1 addition & 1 deletion presets/html-webpack/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/index');
29 changes: 25 additions & 4 deletions presets/preact-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,34 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"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"
},
"./preset": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.12.12",
Expand All @@ -40,6 +57,7 @@
"react-dom": "16.14.0"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"preact": "^10.5.13"
},
"peerDependencies": {
Expand All @@ -52,5 +70,8 @@
"publishConfig": {
"access": "public"
},
"bundlerEntrypoint": [
"./src/index.ts"
],
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec"
}
2 changes: 1 addition & 1 deletion presets/preact-webpack/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/index');
53 changes: 49 additions & 4 deletions presets/react-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,46 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"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"
},
"./preset": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./dist/framework-preset-cra": {
"require": "./dist/framework-preset-cra.js",
"import": "./dist/framework-preset-cra.mjs",
"types": "./dist/framework-preset-cra.d.ts"
},
"./dist/framework-preset-react-docs": {
"require": "./dist/framework-preset-react-docs.js",
"import": "./dist/framework-preset-react-docs.mjs",
"types": "./dist/framework-preset-react-docs.d.ts"
},
"./dist/framework-preset-react-dom-hack": {
"require": "./dist/framework-preset-react-dom-hack.js",
"import": "./dist/framework-preset-react-dom-hack.mjs",
"types": "./dist/framework-preset-react-dom-hack.d.ts"
},
"./dist/framework-preset-react": {
"require": "./dist/framework-preset-react.js",
"import": "./dist/framework-preset-react.mjs",
"types": "./dist/framework-preset-react.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"types/**/*",
Expand All @@ -30,7 +67,7 @@
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@babel/preset-flow": "^7.12.1",
Expand All @@ -50,6 +87,7 @@
"react-refresh": "^0.11.0"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"@types/util-deprecate": "^1.0.0"
},
"peerDependencies": {
Expand All @@ -74,5 +112,12 @@
"publishConfig": {
"access": "public"
},
"bundlerEntrypoint": [
"./src/index.ts",
"./src/framework-preset-cra.ts",
"./src/framework-preset-react-docs.ts",
"./src/framework-preset-react-dom-hack.ts",
"./src/framework-preset-react.ts"
],
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec"
}
2 changes: 1 addition & 1 deletion presets/react-webpack/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/index');
4 changes: 1 addition & 3 deletions presets/react-webpack/src/framework-preset-cra.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { logger } from '@storybook/node-logger';
import type { StorybookConfig } from '@storybook/core-webpack';
import type { Preset, StorybookConfig } from '@storybook/core-webpack';
import { isReactScriptsInstalled } from './cra-config';

type Preset = string | { name: string };

const checkForNewPreset = (presetsList: Preset[]) => {
const hasNewPreset = presetsList.some((preset: Preset) => {
const presetName = typeof preset === 'string' ? preset : preset.name;
Expand Down
8 changes: 4 additions & 4 deletions presets/react-webpack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { StorybookConfig } from './types';
export * from './types';

export const addons: StorybookConfig['addons'] = [
require.resolve('./framework-preset-react'),
require.resolve('./framework-preset-react-dom-hack'),
require.resolve('./framework-preset-cra'),
require.resolve('./framework-preset-react-docs'),
require.resolve('@storybook/preset-react-webpack/dist/framework-preset-react'),
require.resolve('@storybook/preset-react-webpack/dist/framework-preset-react-dom-hack'),
require.resolve('@storybook/preset-react-webpack/dist/framework-preset-cra'),
require.resolve('@storybook/preset-react-webpack/dist/framework-preset-react-docs'),
];
35 changes: 31 additions & 4 deletions presets/server-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,39 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"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"
},
"./preset": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./dist/loader": {
"require": "./dist/loader.js",
"import": "./dist/loader.mjs",
"types": "./dist/loader.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/core-server": "7.0.0-alpha.6",
Expand All @@ -45,6 +67,7 @@
"yaml-loader": "^0.8.0"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"fs-extra": "^9.0.1",
"jest-specific-snapshot": "^4.0.0",
"yaml": "^1.10.0"
Expand All @@ -55,5 +78,9 @@
"publishConfig": {
"access": "public"
},
"bundlerEntrypoint": [
"./src/index.ts",
"./src/loader.ts"
],
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec"
}
2 changes: 1 addition & 1 deletion presets/server-webpack/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/index');
8 changes: 5 additions & 3 deletions presets/server-webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'path';
import type { StorybookConfig } from './types';

export * from './types';
Expand All @@ -9,13 +8,16 @@ export const webpack: StorybookConfig['webpack'] = (config) => {
{
type: 'javascript/auto',
test: /\.stories\.json$/,
use: path.resolve(__dirname, './loader.js'),
use: require.resolve('@storybook/preset-server-webpack/dist/loader'),
},

{
type: 'javascript/auto',
test: /\.stories\.ya?ml/,
use: [path.resolve(__dirname, './loader.js'), require.resolve('yaml-loader')],
use: [
require.resolve('@storybook/preset-server-webpack/dist/loader'),
require.resolve('yaml-loader'),
],
},
];

Expand Down
48 changes: 43 additions & 5 deletions presets/svelte-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,49 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"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"
},
"./preset": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./dist/framework-preset-svelte-docs": {
"require": "./dist/framework-preset-svelte-docs.js",
"import": "./dist/framework-preset-svelte-docs.mjs",
"types": "./dist/framework-preset-svelte-docs.d.ts"
},
"./dist/framework-preset-svelte": {
"require": "./dist/framework-preset-svelte.js",
"import": "./dist/framework-preset-svelte.mjs",
"types": "./dist/framework-preset-svelte.d.ts"
},
"./dist/svelte-docgen-loader": {
"require": "./dist/svelte-docgen-loader.js",
"import": "./dist/svelte-docgen-loader.mjs",
"types": "./dist/svelte-docgen-loader.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"templates/**/*",
"README.md",
"*.js",
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/core-webpack": "7.0.0-alpha.6",
Expand All @@ -42,6 +73,7 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"svelte": "^3.31.2",
"svelte-loader": "^3.1.2"
},
Expand All @@ -56,5 +88,11 @@
"publishConfig": {
"access": "public"
},
"bundlerEntrypoint": [
"./src/index.ts",
"./src/framework-preset-svelte-docs.ts",
"./src/framework-preset-svelte.ts",
"./src/svelte-docgen-loader.ts"
],
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec"
}
2 changes: 1 addition & 1 deletion presets/svelte-webpack/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/index');
Loading

0 comments on commit fcacaf7

Please sign in to comment.