Skip to content

Commit

Permalink
add prebundle script && prebundle lib/theming
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jan 19, 2022
1 parent 151812d commit 3289a41
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,12 @@ module.exports = {
'react/no-unknown-property': 'off', // Need to deactivate otherwise eslint replaces some unknown properties with React ones
},
},
{
// this package uses pre-bundling, dependencies will be bundled, and will be in devDepenencies
files: ['**/lib/theming/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
],
};
24 changes: 17 additions & 7 deletions lib/theming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "ts-node ../../scripts/prebundle.ts"
},
"dependencies": {
"@storybook/client-logger": "6.5.0-alpha.21",
"core-js": "^3.8.2"
},
"devDependencies": {
"@emotion/core": "^10.3.1",
"@emotion/is-prop-valid": "^0.8.6",
"@emotion/styled": "^10.0.27",
"@storybook/client-logger": "6.5.0-alpha.21",
"core-js": "^3.8.2",
"@types/node": "^14.14.20 || ^16.0.0",
"deep-object-diff": "^1.1.0",
"emotion-theming": "^10.0.27",
"global": "^4.4.0",
"memoizerific": "^1.11.3",
"polished": "^4.0.5",
"resolve-from": "^5.0.0",
"ts-dedent": "^2.0.0"
"ts-dedent": "^2.0.0",
"ts-node": "^10.4.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0",
Expand All @@ -60,6 +63,13 @@
"publishConfig": {
"access": "public"
},
"gitHead": "fc1a84084556d61fea8bcaa197f7d85f3a9a107d",
"sbmodern": "dist/modern/index.js"
"bundlerEntrypoint": "./src/index.ts",
"gitHead": "ce3592fc323ede3d33939b532ff7400cfdc1efa1",
"sbmodern": "dist/modern/index.js",
"unbundledDependencies": [
"react",
"react-dom",
"core-js",
"@storybook/client-logger"
]
}
14 changes: 2 additions & 12 deletions lib/theming/paths.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
const { dirname } = require('path');
const resolveFrom = require('resolve-from');

const resolve = resolveFrom.bind(null, __dirname);

// These paths need to be aliased in the manager webpack config to ensure that all
// code running inside the manager uses the *same* versions of each package.
module.exports = {
'@emotion/core': dirname(resolve('@emotion/core/package.json')),
'@emotion/styled': dirname(resolve('@emotion/styled/package.json')),
'emotion-theming': dirname(resolve('emotion-theming/package.json')),
};
// We used to alias paths, but now that we are bundling dependencies, we do not need to
module.exports = {};
2 changes: 1 addition & 1 deletion lib/theming/src/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ export const animation = {
jiggle,
inlineGlow,
hoverable,
};
} as const;
3 changes: 3 additions & 0 deletions lib/theming/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./typings.d.ts" />

import emotionStyled, { CreateStyled } from '@emotion/styled';
import { Theme } from './types';

Expand Down
2 changes: 1 addition & 1 deletion lib/theming/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// todo the following packages need definition files or a TS migration
declare module 'react-inspector';
declare module 'global';
declare module 'global';
13 changes: 9 additions & 4 deletions lib/theming/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
"compilerOptions": {
"rootDir": "./src"
},
"include": [
"src/**/*"
],
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
],
"ts-node": {
"transpileOnly": true,
"files": true,
"compilerOptions": {
"types": ["node"]
}
}
}
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
"dev:babel": "lerna exec --scope \"@storybook/*\" --parallel -- cross-env-shell node \\$LERNA_ROOT_PATH/scripts/utils/watch-babel.js",
"dev:check-types": "tsc --noEmit",
"dev:tsc": "lerna exec --scope \"@storybook/*\" --parallel -- cross-env-shell node \\$LERNA_ROOT_PATH/scripts/utils/watch-tsc.js",
"github-release": "github-release-from-changelog",
"generate-repros": "zx scripts/repros-generator/index.mjs",
"github-release": "github-release-from-changelog",
"linear-export": "ts-node --project=./scripts/tsconfig.json ./scripts/linear-export.ts",
"lint": "yarn lint:js . && yarn lint:md .",
"lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location=.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives",
"lint:md": "remark -q",
"lint:package": "sort-package-json",
"linear-export": "ts-node --project=./scripts/tsconfig.json ./scripts/linear-export.ts",
"local-registry": "ts-node --project=./scripts/tsconfig.json ./scripts/run-registry.ts ",
"publish:debug": "npm run publish:latest -- --npm-tag=debug --no-push",
"publish:latest": "lerna publish --exact --concurrency 1 --force-publish",
Expand Down Expand Up @@ -131,6 +131,11 @@
"@nrwl/nx-cloud": "12.1.1",
"@nrwl/tao": "12.3.4",
"@nrwl/workspace": "12.3.4",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-typescript": "^8.3.0",
"@storybook/addon-a11y": "workspace:*",
"@storybook/addon-actions": "workspace:*",
"@storybook/addon-backgrounds": "workspace:*",
Expand Down Expand Up @@ -200,6 +205,8 @@
"@types/node": "^14.14.20 || ^16.0.0",
"@types/node-cleanup": "^2.1.1",
"@types/prompts": "2.0.11",
"@types/react": "^16",
"@types/react-dom": "^16",
"@types/semver": "^7.3.4",
"@types/serve-static": "^1.13.8",
"@types/shelljs": "^0.8.7",
Expand All @@ -223,6 +230,7 @@
"danger": "^10.6.2",
"detect-port": "^1.3.0",
"downlevel-dts": "^0.6.0",
"dts-bundle-generator": "^6.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.17.0",
Expand Down Expand Up @@ -264,11 +272,15 @@
"prettier": ">=2.2.1 <=2.3.0",
"prompts": "^2.4.0",
"raf": "^3.4.1",
"read-pkg-up": "^7.0.1",
"regenerator-runtime": "^0.13.7",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-lint": "^8.0.0",
"remark-preset-lint-recommended": "^5.0.0",
"rollup": "^2.60.2",
"rollup-plugin-jsx": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
"serve-static": "^1.14.1",
"shelljs": "^0.8.4",
"shx": "^0.3.2",
Expand Down
Loading

0 comments on commit 3289a41

Please sign in to comment.