Skip to content

Commit

Permalink
Merge pull request #24834 from storybookjs/revert-24832-revert-24676-…
Browse files Browse the repository at this point in the history
…experiment-addon-peer-dep

Addons, core: Make `react` and Storybook packages `devDependencies` where possible - ATTEMPT 2
  • Loading branch information
JReinhold authored Nov 15, 2023
2 parents 3ff7b92 + 9b33681 commit df35702
Show file tree
Hide file tree
Showing 93 changed files with 973 additions and 1,226 deletions.
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.cjs')],
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": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts",
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../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",
"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
68 changes: 20 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,41 @@
],
"scripts": {
"check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts",
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"@storybook/global": "^5.0.0",
"@types/uuid": "^9.0.1",
"dequal": "^2.0.2",
"polished": "^4.2.2",
"uuid": "^9.0.0"
},
"devDependencies": {
"@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:*",
"dequal": "^2.0.2",
"lodash": "^4.17.21",
"polished": "^4.2.2",
"prop-types": "^15.7.2",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"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",
"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

0 comments on commit df35702

Please sign in to comment.