@modern-js/core 1.10.1 → 1.11.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/compiled/ajv/package.json +1 -1
  3. package/compiled/ajv/{dist → types}/ajv.d.ts +0 -0
  4. package/compiled/ajv/{dist → types}/compile/codegen/code.d.ts +0 -0
  5. package/compiled/ajv/{dist → types}/compile/codegen/index.d.ts +0 -0
  6. package/compiled/ajv/{dist → types}/compile/codegen/scope.d.ts +0 -0
  7. package/compiled/ajv/{dist → types}/compile/errors.d.ts +0 -0
  8. package/compiled/ajv/{dist → types}/compile/index.d.ts +0 -0
  9. package/compiled/ajv/{dist → types}/compile/ref_error.d.ts +0 -0
  10. package/compiled/ajv/{dist → types}/compile/resolve.d.ts +0 -0
  11. package/compiled/ajv/{dist → types}/compile/rules.d.ts +0 -0
  12. package/compiled/ajv/{dist → types}/compile/util.d.ts +0 -0
  13. package/compiled/ajv/{dist → types}/compile/validate/index.d.ts +0 -0
  14. package/compiled/ajv/{dist → types}/compile/validate/subschema.d.ts +0 -0
  15. package/compiled/ajv/{dist → types}/core.d.ts +0 -0
  16. package/compiled/ajv/{dist → types}/runtime/validation_error.d.ts +0 -0
  17. package/compiled/ajv/{dist → types}/types/index.d.ts +0 -0
  18. package/compiled/ajv/{dist → types}/types/json-schema.d.ts +0 -0
  19. package/compiled/ajv/{dist → types}/types/jtd-schema.d.ts +0 -0
  20. package/dist/bin.d.ts +2 -0
  21. package/dist/bin.js +20 -0
  22. package/dist/config/mergeConfig.d.ts +2 -1
  23. package/dist/config/mergeConfig.js +5 -1
  24. package/dist/config/schema/index.d.ts +3 -0
  25. package/dist/config/schema/tools.d.ts +3 -0
  26. package/dist/config/schema/tools.js +1 -0
  27. package/dist/config/types/index.d.ts +15 -2
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +4 -4
  30. package/dist/loadPlugins.js +1 -1
  31. package/package.json +35 -11
  32. package/.eslintrc.js +0 -9
  33. package/bin/modern-js.js +0 -18
  34. package/dist/cli.d.ts +0 -1
  35. package/dist/cli.js +0 -33
  36. package/jest.config.js +0 -7
  37. package/tsconfig.json +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f66fa0e98: feat: support tools.webpackChain config
8
+
9
+ ### Patch Changes
10
+
11
+ - 1dfe08fcd: feat(webpack): add CHAIN_ID constants for webpack chain
12
+ - Updated dependencies [54fa1dbd6]
13
+ - Updated dependencies [33de0f7ec]
14
+ - @modern-js/plugin@1.3.5
15
+ - @modern-js/utils@1.7.5
16
+
17
+ ## 1.10.3
18
+
19
+ ### Patch Changes
20
+
21
+ - a37960018: refactor: modify deploy microFrontend type
22
+ - Updated dependencies [b8cfc42cd]
23
+ - Updated dependencies [804a5bb8a]
24
+ - @modern-js/utils@1.7.4
25
+
26
+ ## 1.10.2
27
+
28
+ ### Patch Changes
29
+
30
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
31
+ - d9d398e16: add filter logic for merge config
32
+ - Updated dependencies [d5913bd96]
33
+ - Updated dependencies [d32f35134]
34
+ - Updated dependencies [6ae4a34ae]
35
+ - Updated dependencies [b80229c79]
36
+ - Updated dependencies [948cc4436]
37
+ - @modern-js/plugin@1.3.4
38
+ - @modern-js/load-config@1.3.3
39
+ - @modern-js/utils@1.7.3
40
+
3
41
  ## 1.10.1
4
42
 
5
43
  ### Patch Changes
@@ -1 +1 @@
1
- {"name":"ajv","author":"Evgeny Poberezkin","version":"8.11.0","funding":{"type":"github","url":"https://github.com/sponsors/epoberezkin"},"license":"MIT","types":"dist/ajv.d.ts"}
1
+ {"name":"ajv","author":"Evgeny Poberezkin","version":"8.11.0","funding":{"type":"github","url":"https://github.com/sponsors/epoberezkin"},"license":"MIT","types":"types/ajv.d.ts"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require('../compiled/v8-compile-cache');
5
+ // eslint-disable-next-line import/first
6
+ const _1 = require(".");
7
+ if (!process.env.NODE_ENV) {
8
+ const command = process.argv[2];
9
+ if (['build', 'start', 'deploy'].includes(command)) {
10
+ process.env.NODE_ENV = 'production';
11
+ }
12
+ else if (command === 'test') {
13
+ process.env.NODE_ENV = 'test';
14
+ }
15
+ else {
16
+ process.env.NODE_ENV = 'development';
17
+ }
18
+ }
19
+ const { version } = require('../package.json');
20
+ _1.cli.run(process.argv.slice(2), { version });
@@ -3,8 +3,9 @@ export interface NormalizedSourceConfig extends Omit<SourceConfig, 'alias' | 'mo
3
3
  alias: SourceConfig['alias'] | Array<SourceConfig['alias']>;
4
4
  moduleScopes: SourceConfig['moduleScopes'] | Array<SourceConfig['moduleScopes']>;
5
5
  }
6
- export interface NormalizedToolsConfig extends Omit<ToolsConfig, 'webpack' | 'babel' | 'postcss' | 'autoprefixer' | 'lodash' | 'tsLoader' | 'terser' | 'minifyCss' | 'esbuild' | 'styledComponents'> {
6
+ export interface NormalizedToolsConfig extends Omit<ToolsConfig, 'webpack' | 'webpackChain' | 'babel' | 'postcss' | 'autoprefixer' | 'lodash' | 'tsLoader' | 'terser' | 'minifyCss' | 'esbuild' | 'styledComponents'> {
7
7
  webpack: ToolsConfig['webpack'] | Array<NonNullable<ToolsConfig['webpack']>>;
8
+ webpackChain: ToolsConfig['webpackChain'] | Array<NonNullable<ToolsConfig['webpackChain']>>;
8
9
  babel: ToolsConfig['babel'] | Array<NonNullable<ToolsConfig['babel']>>;
9
10
  postcss: ToolsConfig['postcss'] | Array<NonNullable<ToolsConfig['postcss']>>;
10
11
  styledComponents: ToolsConfig['styledComponents'] | Array<NonNullable<ToolsConfig['styledComponents']>>;
@@ -9,7 +9,11 @@ const utils_1 = require("@modern-js/utils");
9
9
  * @param configs - Configuration from modern.config.ts or plugin's config hook.
10
10
  * @returns - normalized user config.
11
11
  */
12
- const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source) => {
12
+ const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
13
+ // Do not use the following merge logic for source.designSystem and tools.tailwind(css)
14
+ if (key === 'designSystem' || key === 'tailwind' || key === 'tailwindcss') {
15
+ return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
16
+ }
13
17
  if (Array.isArray(target)) {
14
18
  if (Array.isArray(source)) {
15
19
  return [...target, ...source];
@@ -432,6 +432,9 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
432
432
  webpack: {
433
433
  typeof: string[];
434
434
  };
435
+ webpackChain: {
436
+ typeof: string[];
437
+ };
435
438
  babel: {
436
439
  typeof: string[];
437
440
  };
@@ -5,6 +5,9 @@ export declare const tools: {
5
5
  webpack: {
6
6
  typeof: string[];
7
7
  };
8
+ webpackChain: {
9
+ typeof: string[];
10
+ };
8
11
  babel: {
9
12
  typeof: string[];
10
13
  };
@@ -6,6 +6,7 @@ exports.tools = {
6
6
  additionalProperties: false,
7
7
  properties: {
8
8
  webpack: { typeof: ['object', 'function'] },
9
+ webpackChain: { typeof: ['function'] },
9
10
  babel: { typeof: ['object', 'function'] },
10
11
  postcss: { typeof: ['object', 'function'] },
11
12
  lodash: { typeof: ['object', 'function'] },
@@ -5,7 +5,8 @@ import type { MetaOptions } from '@modern-js/utils';
5
5
  import type { TransformOptions } from '@babel/core';
6
6
  import type webpack from 'webpack';
7
7
  import type { Configuration as WebpackConfiguration } from 'webpack';
8
- import autoprefixer from 'autoprefixer';
8
+ import type { ChainIdentifier, WebpackChain } from '@modern-js/webpack';
9
+ import type autoprefixer from 'autoprefixer';
9
10
  import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
10
11
  import type { PluginConfig } from '../../loadPlugins';
11
12
  import type { TestConfig, JestConfig } from './test';
@@ -133,7 +134,7 @@ export interface MicroFrontend {
133
134
  moduleApp?: string;
134
135
  }
135
136
  export interface DeployConfig {
136
- microFrontend?: false | MicroFrontend;
137
+ microFrontend?: boolean | MicroFrontend;
137
138
  domain?: string | Array<string>;
138
139
  domainByEntries?: Record<string, string | Array<string>>;
139
140
  }
@@ -148,14 +149,26 @@ export declare type DevServerConfig = {
148
149
  };
149
150
  export declare type WebpackConfig = WebpackConfiguration | ((config: WebpackConfiguration, utils: {
150
151
  env: string;
152
+ name: string;
151
153
  webpack: typeof webpack;
154
+ /**
155
+ * @deprecated please use `tools.webpackChain` instead.
156
+ */
157
+ chain: WebpackChain;
152
158
  [key: string]: any;
153
159
  }) => WebpackConfiguration | void);
160
+ export declare type WebpackChainConfig = (chain: WebpackChain, utils: {
161
+ env: string;
162
+ name: string;
163
+ webpack: typeof webpack;
164
+ CHAIN_ID: ChainIdentifier;
165
+ }) => void;
154
166
  export declare type BabelConfig = TransformOptions | ((config: TransformOptions, utils?: any) => TransformOptions | void);
155
167
  export declare type AutoprefixerConfig = AutoprefixerOptions | ((config: AutoprefixerOptions) => AutoprefixerOptions | void);
156
168
  export declare type TerserConfig = TerserOptions | ((config: TerserOptions) => TerserOptions | void);
157
169
  export interface ToolsConfig {
158
170
  webpack?: WebpackConfig;
171
+ webpackChain?: WebpackChainConfig;
159
172
  babel?: BabelConfig;
160
173
  autoprefixer?: AutoprefixerConfig;
161
174
  postcss?: ConfigFunction;
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export type { PluginAPI } from './pluginAPI';
15
15
  export type { NormalizedConfig, IAppContext };
16
16
  declare const initAppDir: (cwd?: string | undefined) => Promise<string>;
17
17
  export interface CoreOptions {
18
+ version?: string;
18
19
  configFile?: string;
19
20
  serverConfigFile?: string;
20
21
  packageJsonConfig?: string;
@@ -29,6 +30,7 @@ export interface CoreOptions {
29
30
  };
30
31
  }
31
32
  export declare const mergeOptions: (options?: CoreOptions | undefined) => {
33
+ version?: string | undefined;
32
34
  configFile?: string | undefined;
33
35
  serverConfigFile: string;
34
36
  packageJsonConfig?: string | undefined;
package/dist/index.js CHANGED
@@ -43,10 +43,6 @@ Object.defineProperty(exports, "ResolvedConfigContext", { enumerable: true, get:
43
43
  Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return pluginAPI_1.useAppContext; } });
44
44
  Object.defineProperty(exports, "useConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useConfigContext; } });
45
45
  Object.defineProperty(exports, "useResolvedConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useResolvedConfigContext; } });
46
- utils_1.program
47
- .name('modern')
48
- .usage('<command> [options]')
49
- .version(process.env.MODERN_JS_VERSION || '0.1.0');
50
46
  const initAppDir = async (cwd) => {
51
47
  if (!cwd) {
52
48
  // eslint-disable-next-line no-param-reassign
@@ -69,6 +65,9 @@ const mergeOptions = (options) => {
69
65
  };
70
66
  };
71
67
  exports.mergeOptions = mergeOptions;
68
+ const setProgramVersion = (version = 'unknown') => {
69
+ utils_1.program.name('modern').usage('<command> [options]').version(version);
70
+ };
72
71
  const createCli = () => {
73
72
  let hooksRunner;
74
73
  let isRestart = false;
@@ -82,6 +81,7 @@ const createCli = () => {
82
81
  restartOptions = mergedOptions;
83
82
  const appDirectory = await initAppDir();
84
83
  (0, commander_1.initCommandsMap)();
84
+ setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
85
85
  const metaName = (_b = (_a = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options) === null || _a === void 0 ? void 0 : _a.metaName) !== null && _b !== void 0 ? _b : 'MODERN';
86
86
  (0, loadEnv_1.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
87
87
  const loaded = await (0, config_1.loadUserConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
@@ -31,7 +31,7 @@ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
31
31
  .filter(name => {
32
32
  const config = allPlugins[name];
33
33
  if (config.forced === true) {
34
- // 参考 packages/cli/core/src/cli.ts 文件
34
+ // 参考 packages/cli/core/src/bin.ts 文件
35
35
  return true;
36
36
  }
37
37
  return (0, utils_1.isDepExists)(appDirectory, name);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.10.1",
14
+ "version": "1.11.0-beta.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -27,8 +27,8 @@
27
27
  "default": "./dist/index.js"
28
28
  },
29
29
  "./bin": {
30
- "jsnext:source": "./src/cli.ts",
31
- "default": "./bin/modern-js.js"
30
+ "jsnext:source": "./src/bin.ts",
31
+ "default": "./dist/bin.js"
32
32
  }
33
33
  },
34
34
  "typesVersions": {
@@ -38,20 +38,21 @@
38
38
  ]
39
39
  }
40
40
  },
41
- "bin": "./bin/modern-js.js",
41
+ "bin": "./dist/bin.js",
42
42
  "dependencies": {
43
- "@modern-js/load-config": "^1.3.2",
44
- "@modern-js/plugin": "^1.3.3",
45
- "@modern-js/utils": "^1.7.2"
43
+ "@modern-js/load-config": "^1.3.3",
44
+ "@modern-js/plugin": "^1.3.5",
45
+ "@modern-js/utils": "^1.7.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@jest/types": "^27.0.6",
49
- "@modern-js/types": "1.5.2",
49
+ "@modern-js/types": "1.5.3",
50
+ "@modern-js/webpack": "1.8.0",
50
51
  "@scripts/build": "0.0.0",
51
52
  "@scripts/jest-config": "0.0.0",
52
53
  "@types/babel__code-frame": "^7.0.3",
53
54
  "@types/babel__core": "^7.1.16",
54
- "@types/jest": "^26",
55
+ "@types/jest": "^27",
55
56
  "@types/less": "^3.0.3",
56
57
  "@types/node": "^14",
57
58
  "@types/react": "^17",
@@ -70,11 +71,34 @@
70
71
  "registry": "https://registry.npmjs.org/",
71
72
  "access": "public"
72
73
  },
74
+ "wireit": {
75
+ "build": {
76
+ "command": "tsc",
77
+ "files": [
78
+ "src/**/*",
79
+ "tsconfig.json",
80
+ "package.json"
81
+ ],
82
+ "output": [
83
+ "dist/**/*"
84
+ ]
85
+ },
86
+ "test": {
87
+ "command": "jest",
88
+ "files": [
89
+ "src/**/*",
90
+ "tsconfig.json",
91
+ "package.json",
92
+ "tests/**/*"
93
+ ],
94
+ "output": []
95
+ }
96
+ },
73
97
  "scripts": {
74
98
  "new": "modern new",
75
- "build": "tsc",
99
+ "build": "wireit",
76
100
  "dev": "tsc --watch",
77
- "test": "jest"
101
+ "test": "wireit"
78
102
  },
79
103
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
80
104
  }
package/.eslintrc.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['@modern-js'],
4
- ignorePatterns: ['compiled/'],
5
- parserOptions: {
6
- tsconfigRootDir: __dirname,
7
- project: ['./tsconfig.json'],
8
- },
9
- };
package/bin/modern-js.js DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('../compiled/v8-compile-cache');
4
- const { cli } = require('../');
5
- const { version } = require('../package.json');
6
-
7
- process.env.MODERN_JS_VERSION = version;
8
- if (!process.env.NODE_ENV) {
9
- process.env.NODE_ENV =
10
- // eslint-disable-next-line no-nested-ternary
11
- ['build', 'start', 'deploy'].indexOf(process.argv[2]) !== -1
12
- ? 'production'
13
- : process.argv[2] === 'test'
14
- ? 'test'
15
- : 'development';
16
- }
17
-
18
- cli.run(process.argv.slice(2));
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/cli.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- // 这个文件跟 bin/modern-js.js 基本一样
3
- // 在开发阶段,因为 package.json 的 exports['./bin']['jsnext:source'] 配置
4
- // 了这个文件,所以需要保留, 后续如果找到更好的方式之后会移除这个文件
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const path_1 = __importDefault(require("path"));
10
- const _1 = require(".");
11
- const { version } = require('../package.json');
12
- // XXX: 通过这个方式去掉了 package.json 里面对于 @modern-js/module-tools 的 devDependencies 依赖
13
- // 然后可以正常的执行 modern build
14
- const kModuleToolsCliPath = path_1.default.resolve(__dirname, '../../../solutions/module-tools/src/index.ts');
15
- process.env.MODERN_JS_VERSION = version;
16
- if (!process.env.NODE_ENV) {
17
- process.env.NODE_ENV =
18
- // eslint-disable-next-line no-nested-ternary
19
- ['build', 'start', 'deploy'].includes(process.argv[2])
20
- ? 'production'
21
- : process.argv[2] === 'test'
22
- ? 'test'
23
- : 'development';
24
- }
25
- _1.cli.run(process.argv.slice(2), {
26
- plugins: {
27
- '@modern-js/module-tools': {
28
- cli: kModuleToolsCliPath,
29
- // 是否需要强制加载这个组件,跳过 loadPlugins 里面 filter 的检测逻辑
30
- forced: true,
31
- },
32
- },
33
- });
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "target": "ES2019",
5
- "declaration": true,
6
- "outDir": "./dist",
7
- "baseUrl": "./",
8
- "isolatedModules": true,
9
- "esModuleInterop": true
10
- },
11
- "include": ["src"]
12
- }