From ed80d6ed0a77060cabb268faff3ac800bda5becd Mon Sep 17 00:00:00 2001 From: xuchaobei Date: Tue, 26 Jul 2022 19:05:04 +0800 Subject: [PATCH] build: build modern js dist (#57) * build: build modern js * chore: update modern-js * style: use prettier as default formatter * chore: changeset --- .changeset/pink-pianos-swim.md | 12 +++++++++++ .prettierrc | 5 +++++ .vscode/settings.json | 9 +++------ common/config.js | 20 +++++++++++++++++++ package.json | 4 ++-- .../plugins/auto-actions/modern.config.js | 5 +++-- packages/plugins/auto-actions/package.json | 4 ++-- packages/plugins/devtools/modern.config.js | 5 +++-- packages/plugins/devtools/package.json | 4 ++-- packages/plugins/effects/modern.config.js | 5 +++-- packages/plugins/effects/package.json | 4 ++-- packages/plugins/immer/modern.config.js | 5 +++-- packages/plugins/immer/package.json | 4 ++-- .../plugins/xstate-immer/modern.config.js | 5 +++-- packages/plugins/xstate-immer/package.json | 4 ++-- packages/plugins/xstate/modern.config.js | 5 +++-- packages/plugins/xstate/package.json | 4 ++-- packages/react/modern.config.js | 5 +++-- packages/react/package.json | 6 +++--- packages/store/modern.config.js | 5 +++-- packages/store/package.json | 6 +++--- 21 files changed, 84 insertions(+), 42 deletions(-) create mode 100644 .changeset/pink-pianos-swim.md create mode 100644 .prettierrc create mode 100644 common/config.js diff --git a/.changeset/pink-pianos-swim.md b/.changeset/pink-pianos-swim.md new file mode 100644 index 000000000..e81a636ae --- /dev/null +++ b/.changeset/pink-pianos-swim.md @@ -0,0 +1,12 @@ +--- +'@modern-js-reduck/plugin-auto-actions': patch +'@modern-js-reduck/plugin-devtools': patch +'@modern-js-reduck/plugin-effects': patch +'@modern-js-reduck/plugin-immutable': patch +'@modern-js-reduck/plugin-xstate': patch +'@modern-js-reduck/plugin-xstate-immer': patch +'@modern-js-reduck/react': patch +'@modern-js-reduck/store': patch +--- + +build: build modern js dist diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..5393aaf2d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "arrowParens": "avoid" +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 5b2e7f4b3..89427713c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,16 +57,13 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascriptreact]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescript]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescriptreact]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" - }, - "[vue]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "eslint.alwaysShowStatus": true, // "eslint.nodePath": "./node_modules", diff --git a/common/config.js b/common/config.js new file mode 100644 index 000000000..fc12efb66 --- /dev/null +++ b/common/config.js @@ -0,0 +1,20 @@ +module.exports = { + tools: { + babel: config => { + const { presets } = config; + for (const preset of presets) { + if (preset[0].includes('@babel/preset-env')) { + preset[1] = { + targets: { + esmodules: true, + }, + // Use the equivalent of `babel-preset-modules` + bugfixes: true, + modules: false, + loose: true, + }; + } + } + }, + }, +}; diff --git a/package.json b/package.json index 04e2111b4..57080c36c 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,8 @@ "devDependencies": { "@commitlint/cli": "^17.0.0", "@commitlint/config-conventional": "^17.0.0", - "@modern-js/monorepo-tools": "^1.4.6", - "@modern-js/plugin-jarvis": "^1.2.12", + "@modern-js/monorepo-tools": "^1.5.0", + "@modern-js/plugin-jarvis": "^1.2.14", "@modern-js/tsconfig": "^1.2.0", "husky": "^8.0.0", "webpack": "^5.54.0" diff --git a/packages/plugins/auto-actions/modern.config.js b/packages/plugins/auto-actions/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/auto-actions/modern.config.js +++ b/packages/plugins/auto-actions/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/auto-actions/package.json b/packages/plugins/auto-actions/package.json index 50662b8fa..b00936c57 100644 --- a/packages/plugins/auto-actions/package.json +++ b/packages/plugins/auto-actions/package.json @@ -42,8 +42,8 @@ }, "devDependencies": { "@modern-js-reduck/store": "^1.0.1", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@types/jest": "^27.5.1", "@types/node": "^14", "@types/react": "^17", diff --git a/packages/plugins/devtools/modern.config.js b/packages/plugins/devtools/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/devtools/modern.config.js +++ b/packages/plugins/devtools/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/devtools/package.json b/packages/plugins/devtools/package.json index 8c5759a70..15fe99d34 100644 --- a/packages/plugins/devtools/package.json +++ b/packages/plugins/devtools/package.json @@ -44,8 +44,8 @@ }, "devDependencies": { "@modern-js-reduck/store": "^1.0.4", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@types/jest": "^27.5.1", "@types/node": "^14", "@types/react": "^17", diff --git a/packages/plugins/effects/modern.config.js b/packages/plugins/effects/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/effects/modern.config.js +++ b/packages/plugins/effects/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/effects/package.json b/packages/plugins/effects/package.json index 7807b3ad3..05ef08252 100644 --- a/packages/plugins/effects/package.json +++ b/packages/plugins/effects/package.json @@ -45,8 +45,8 @@ }, "devDependencies": { "@modern-js-reduck/store": "^1.0.1", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@types/jest": "^27.5.1", "@types/node": "^14", "@types/react": "^17", diff --git a/packages/plugins/immer/modern.config.js b/packages/plugins/immer/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/immer/modern.config.js +++ b/packages/plugins/immer/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/immer/package.json b/packages/plugins/immer/package.json index a6e2a3351..efcad3224 100644 --- a/packages/plugins/immer/package.json +++ b/packages/plugins/immer/package.json @@ -43,8 +43,8 @@ }, "devDependencies": { "@modern-js-reduck/store": "^1.0.1", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@types/jest": "^27.5.1", "@types/node": "^14", "@types/react": "^17", diff --git a/packages/plugins/xstate-immer/modern.config.js b/packages/plugins/xstate-immer/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/xstate-immer/modern.config.js +++ b/packages/plugins/xstate-immer/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/xstate-immer/package.json b/packages/plugins/xstate-immer/package.json index 58551c2e3..e2b2f94ed 100644 --- a/packages/plugins/xstate-immer/package.json +++ b/packages/plugins/xstate-immer/package.json @@ -46,8 +46,8 @@ "@modern-js-reduck/plugin-xstate": "^1.0.1", "@modern-js-reduck/react": "^1.0.1", "@modern-js-reduck/store": "^1.0.1", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", "@types/jest": "^27.5.1", diff --git a/packages/plugins/xstate/modern.config.js b/packages/plugins/xstate/modern.config.js index b2f719793..b8a40cb51 100644 --- a/packages/plugins/xstate/modern.config.js +++ b/packages/plugins/xstate/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../../common/config'); + +module.exports = config; diff --git a/packages/plugins/xstate/package.json b/packages/plugins/xstate/package.json index 538652935..a5774b7e9 100644 --- a/packages/plugins/xstate/package.json +++ b/packages/plugins/xstate/package.json @@ -41,8 +41,8 @@ "devDependencies": { "@modern-js-reduck/react": "^1.0.1", "@modern-js-reduck/store": "^1.0.4", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", "@types/jest": "^27.5.1", diff --git a/packages/react/modern.config.js b/packages/react/modern.config.js index b2f719793..f41d6905c 100644 --- a/packages/react/modern.config.js +++ b/packages/react/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../common/config'); + +module.exports = config; diff --git a/packages/react/package.json b/packages/react/package.json index 2230f5496..a44b8f807 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -41,9 +41,8 @@ "invariant": "^2.2.4" }, "devDependencies": { - "create-react-class": "15.7.0", - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", "@types/invariant": "^2.2.34", @@ -52,6 +51,7 @@ "@types/react": "^17", "@types/react-dom": "^17", "@types/testing-library__jest-dom": "^5.14.1", + "create-react-class": "15.7.0", "react": "^17.0.2", "react-dom": "^17.0.2", "redux": "^4.1.1", diff --git a/packages/store/modern.config.js b/packages/store/modern.config.js index b2f719793..f41d6905c 100644 --- a/packages/store/modern.config.js +++ b/packages/store/modern.config.js @@ -1,2 +1,3 @@ -/** @type {import('@modern-js/module-tools').UserConfig} */ -module.exports = {}; +const config = require('../../common/config'); + +module.exports = config; diff --git a/packages/store/package.json b/packages/store/package.json index 12f74fe0b..8dc663633 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -65,9 +65,9 @@ "redux": "^4.1.1" }, "devDependencies": { - "@modern-js/module-tools": "^1.5.3", - "@modern-js/plugin-testing": "^1.5.5", - "@modern-js/runtime": "^1.3.0", + "@modern-js/module-tools": "^1.7.1", + "@modern-js/plugin-testing": "^1.6.0", + "@modern-js/runtime": "^1.3.5", "@types/jest": "^27.5.1", "@types/node": "^14", "@types/react": "^17",