Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons, core: Make react and Storybook packages devDependencies where possible #24676

Merged
merged 28 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1ad0785
move react and @storybook from peer deps to dev deps
JReinhold Oct 31, 2023
c2b2b1a
globalize packages when bundling
JReinhold Oct 31, 2023
ab399bd
use separate bundling technique for addons, manager packages
JReinhold Nov 2, 2023
51f2cf9
update eslint rules
JReinhold Nov 2, 2023
c841f89
Merge branch 'next' of github.com:storybookjs/storybook into experime…
JReinhold Nov 2, 2023
d1b9518
fix blocks dep
JReinhold Nov 2, 2023
1388c64
move Vite deps otimization to presets
JReinhold Nov 2, 2023
f2a0396
Merge branch 'next' into experiment-addon-peer-dep
ndelangen Nov 2, 2023
d43b004
fixes for types check
ndelangen Nov 2, 2023
642cfd7
fix
ndelangen Nov 2, 2023
0149d22
fix
ndelangen Nov 2, 2023
88e116a
remove need for prop-types in preact
ndelangen Nov 2, 2023
c596b98
fix event-log-checker
ndelangen Nov 3, 2023
4ea32f3
Discard changes to scripts/event-log-checker.ts
ndelangen Nov 3, 2023
1d9cc82
fix
ndelangen Nov 3, 2023
a7a0b23
Merge branch 'experiment-addon-peer-dep' of github.com:storybookjs/st…
ndelangen Nov 3, 2023
7120771
fix types export from manager-api
JReinhold Nov 3, 2023
0551bec
rename optimizeDeps > optimizeViteDeps
JReinhold Nov 3, 2023
c31f632
refactor and simplify preview globalization
JReinhold Nov 3, 2023
4e59075
refactor manager+preview bundling and globals
JReinhold Nov 5, 2023
54ab656
Merge branch 'next' of github.com:storybookjs/storybook into experime…
JReinhold Nov 5, 2023
fdee9bf
reword missing react error
JReinhold Nov 5, 2023
765dbb1
make global types more strict
JReinhold Nov 5, 2023
b5a5307
keep SB packages as regular dependencies of manager-api
JReinhold Nov 7, 2023
5f8223c
fix ts-dedent missing from svelte renderer
JReinhold Nov 7, 2023
7d703fa
Merge branch 'next' into experiment-addon-peer-dep
JReinhold Nov 7, 2023
214a6f8
add import entry to globals exports
JReinhold Nov 8, 2023
94abc13
Merge branch 'next' into experiment-addon-peer-dep
JReinhold Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 60 additions & 13 deletions code/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
const path = require('path');
const fs = require('fs');

const scriptPath = path.join(__dirname, '..', 'scripts');

const addonsPackages = fs
.readdirSync(path.join(__dirname, 'addons'))
.filter((p) => fs.statSync(path.join(__dirname, 'addons', p)).isDirectory());
const libPackages = fs
.readdirSync(path.join(__dirname, 'lib'))
.filter((p) => fs.statSync(path.join(__dirname, 'lib', p)).isDirectory());
const uiPackages = fs
.readdirSync(path.join(__dirname, 'ui'))
.filter((p) => fs.statSync(path.join(__dirname, 'ui', p)).isDirectory())
.filter((p) => !p.startsWith('.'));

module.exports = {
root: true,
extends: [path.join(scriptPath, '.eslintrc.js')],
Expand Down Expand Up @@ -53,7 +65,6 @@ module.exports = {
project: null,
},
rules: {
// '@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-throw-literal': 'off',
Expand All @@ -77,15 +88,7 @@ module.exports = {
},
{
// these packages use pre-bundling, dependencies will be bundled, and will be in devDepenencies
files: [
'addons/**/*',
'frameworks/**/*',
'lib/**/*',
'builders/**/*',
'deprecated/**/*',
'renderers/**/*',
'ui/**/*',
],
files: ['frameworks/**/*', 'builders/**/*', 'deprecated/**/*', 'renderers/**/*'],
excludedFiles: ['frameworks/angular/**/*', 'frameworks/ember/**/*', 'lib/core-server/**/*'],
rules: {
'import/no-extraneous-dependencies': [
Expand All @@ -95,11 +98,47 @@ module.exports = {
},
},
{
files: ['**/ui/*', '**/ui/.storybook/*'],
files: ['**/ui/.storybook/**'],
rules: {
'import/no-extraneous-dependencies': ['error', { packageDir: __dirname }],
'import/no-extraneous-dependencies': [
'error',
{ packageDir: [__dirname], devDependencies: true },
],
},
},
...addonsPackages.map((directory) => ({
files: [path.join('**', 'addons', directory, '**', '*.*')],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
packageDir: [__dirname, path.join(__dirname, 'addons', directory)],
devDependencies: true,
},
],
},
})),
...uiPackages.map((directory) => ({
files: [path.join('**', 'ui', directory, '**', '*.*')],
rules: {
'import/no-extraneous-dependencies': [
'error',
{ packageDir: [__dirname, path.join(__dirname, 'ui', directory)], devDependencies: true },
],
},
})),
...libPackages.map((directory) => ({
files: [path.join('**', 'lib', directory, '**', '*.*')],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
packageDir: [__dirname, path.join(__dirname, 'lib', directory)],
devDependencies: true,
},
],
},
})),
{
files: [
'**/__tests__/**',
Expand All @@ -121,16 +160,24 @@ module.exports = {
'react/require-default-props': 'off',
},
},
{ files: '**/.storybook/config.js', rules: { 'global-require': 'off' } },
{
files: ['**/*.stories.*'],
rules: {
'no-console': 'off',
},
},
{
files: ['**/renderers/preact/**/*'],
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
},
},
{
files: ['**/*.tsx', '**/*.ts'],
rules: {
'no-shadow': 'off',
'@typescript-eslint/ban-types': 'warn', // should become error, in the future
'react/require-default-props': 'off',
'react/prop-types': 'off', // we should use types
'react/forbid-prop-types': 'off', // we should use types
Expand Down
55 changes: 18 additions & 37 deletions code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,9 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./manager": {
"types": "./dist/manager.d.ts",
"require": "./dist/manager.js",
"import": "./dist/manager.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./register": {
"types": "./dist/manager.d.ts",
"require": "./dist/manager.js",
"import": "./dist/manager.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
"main": "dist/index.js",
Expand All @@ -61,47 +49,40 @@
],
"scripts": {
"check": "../../../scripts/prepare/check.ts",
"prep": "../../../scripts/prepare/bundle.ts"
"prep": "../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"@storybook/addon-highlight": "workspace:*",
"axe-core": "^4.2.0"
},
"devDependencies": {
"@storybook/channels": "workspace:*",
"@storybook/client-logger": "workspace:*",
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
"@storybook/types": "workspace:*",
"axe-core": "^4.2.0",
"lodash": "^4.17.21",
"react-resize-detector": "^7.1.2"
},
"devDependencies": {
"@testing-library/react": "^11.2.2",
"lodash": "^4.17.21",
"react": "^16.8.0",
"react-dom": "^16.8.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if the react-dom dep is needed truly in these addons?

It's not a big deal at all having them as devDependencies of course, no harm to users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I added it as a todo to my cooldown period.

  • Remove react-dom from package.jsons when not needed
  • Audit dependencies of frameworks+renderers, they might have a lot of unused @storybook dependencies we can remove

"react-resize-detector": "^7.1.2",
"resize-observer-polyfill": "^1.5.1",
"typescript": "~4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
},
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts",
"./src/manager.tsx",
"exportEntries": [
"./src/index.ts"
],
"managerEntries": [
"./src/manager.tsx"
],
"previewEntries": [
"./src/preview.tsx"
]
},
Expand Down
72 changes: 24 additions & 48 deletions code/addons/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,9 @@
"require": "./dist/decorator.js",
"import": "./dist/decorator.mjs"
},
"./manager": {
"types": "./dist/manager.d.ts",
"require": "./dist/manager.js",
"import": "./dist/manager.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./register.js": {
"types": "./dist/manager.d.ts",
"require": "./dist/manager.js",
"import": "./dist/manager.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register.js": "./dist/manager.js",
"./package.json": "./package.json"
},
"main": "dist/index.js",
Expand All @@ -58,14 +46,8 @@
"*": [
"dist/index.d.ts"
],
"manager": [
"dist/manager.d.ts"
],
"decorator": [
"dist/decorator.d.ts"
],
"preview": [
"dist/preview.d.ts"
]
}
},
Expand All @@ -78,51 +60,45 @@
],
"scripts": {
"check": "../../../scripts/prepare/check.ts",
"prep": "../../../scripts/prepare/bundle.ts"
"prep": "../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"@storybook/client-logger": "workspace:*",
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
"@storybook/types": "workspace:*",
"@types/lodash": "^4.14.167",
"@types/uuid": "^9.0.1",
"dequal": "^2.0.2",
"lodash": "^4.17.21",
"polished": "^4.2.2",
"prop-types": "^15.7.2",
"react-inspector": "^6.0.0",
"telejson": "^7.2.0",
"ts-dedent": "^2.0.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/lodash": "^4.14.167",
"@types/uuid": "^9.0.1",
"@storybook/client-logger": "workspace:*",
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
"@storybook/types": "workspace:*",
"prop-types": "^15.7.2",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react-inspector": "^6.0.0",
"typescript": "~4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
},
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts",
"exportEntries": [
"./src/decorator.ts",
"./src/manager.tsx",
"./src/index.ts"
],
"managerEntries": [
"./src/manager.tsx"
],
"previewEntries": [
"./src/preview.ts"
]
},
Expand Down
Loading