@modern-js/module-tools 1.19.0 → 1.20.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [49515c5]
8
+ - @modern-js/utils@1.20.1
9
+ - @modern-js/babel-preset-module@1.20.1
10
+ - @modern-js/core@1.20.1
11
+ - @modern-js/css-config@1.20.1
12
+ - @modern-js/plugin-changeset@1.20.1
13
+ - @modern-js/plugin-i18n@1.20.1
14
+ - @modern-js/plugin-jarvis@1.20.1
15
+ - @modern-js/new-action@1.20.1
16
+ - @modern-js/babel-compiler@1.20.1
17
+ - @modern-js/style-compiler@1.20.1
18
+ - @modern-js/upgrade@1.20.1
19
+ - @modern-js/plugin@1.20.1
20
+
21
+ ## 1.20.0
22
+
23
+ ### Patch Changes
24
+
25
+ - fffceae: fix: extends path error
26
+ fix: 修复 extends 字段路径的问题
27
+ - a4f8761: feat: add afterDev hook
28
+ feat: 添加 afterDev 钩子
29
+ - 3e5ad1e: chore: move copyTask from bundleless task to build task
30
+ chore: 把 copy 任务从 bundleless 任务中移动到 build 任务中
31
+ - Updated dependencies [d5d570b]
32
+ - Updated dependencies [4ddc185]
33
+ - Updated dependencies [df8ee7e]
34
+ - Updated dependencies [8c05089]
35
+ - Updated dependencies [d5d570b]
36
+ - @modern-js/utils@1.20.0
37
+ - @modern-js/core@1.20.0
38
+ - @modern-js/plugin-changeset@1.20.0
39
+ - @modern-js/babel-preset-module@1.20.0
40
+ - @modern-js/css-config@1.20.0
41
+ - @modern-js/plugin-i18n@1.20.0
42
+ - @modern-js/plugin-jarvis@1.20.0
43
+ - @modern-js/new-action@1.20.0
44
+ - @modern-js/babel-compiler@1.20.0
45
+ - @modern-js/style-compiler@1.20.0
46
+ - @modern-js/upgrade@1.20.0
47
+ - @modern-js/plugin@1.20.0
48
+
3
49
  ## 1.19.0
4
50
 
5
51
  ### Patch Changes
@@ -3,6 +3,9 @@ const local = Import.lazy('../locale', require);
3
3
  const commands = Import.lazy('../commands', require);
4
4
  export const devCli = (program, api) => {
5
5
  program.command('dev [subCmd]').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async (subCmd, params) => {
6
- await commands.dev(api, params, subCmd);
6
+ await commands.dev(api, params, subCmd); // support plugin-proxy
7
+
8
+ const runner = api.useHookRunners();
9
+ await runner.afterDev();
7
10
  });
8
11
  };
@@ -26,8 +26,6 @@ const watchAssets = (api, {
26
26
  targetDir,
27
27
  outputDir
28
28
  }) => {
29
- const appContext = api.useAppContext();
30
- const modernConfig = api.useResolvedConfigContext();
31
29
  watch(`${targetDir}/**/*.*`, async ({
32
30
  changeType,
33
31
  changedFilePath
@@ -40,10 +38,6 @@ const watchAssets = (api, {
40
38
 
41
39
  const file = path.relative(targetDir, changedFilePath);
42
40
  fs.copyFileSync(changedFilePath, path.resolve(outputDir, file));
43
- await copyUtils.copyTask({
44
- modernConfig,
45
- appContext
46
- });
47
41
  }, ['**/*.{js,jsx,ts,tsx,d.ts,scss,less,css,sass}']);
48
42
  };
49
43
 
@@ -40,6 +40,11 @@ export const generatorTsConfig = (projectTsconfig, {
40
40
  include,
41
41
  exclude
42
42
  };
43
+
44
+ if (projectTsconfig.extends) {
45
+ resetConfig.extends = projectTsconfig.extends.startsWith('.') ? path.join(resolvePath, projectTsconfig.extends) : projectTsconfig.extends;
46
+ }
47
+
43
48
  const recommendOption = {
44
49
  // Ensure that Babel can safely transpile files in the TypeScript project
45
50
  compilerOptions: {
@@ -9,6 +9,7 @@ import { getAllDeps } from "./utils";
9
9
  const bundle = Import.lazy('./bundle', require);
10
10
  const bundleless = Import.lazy('./bundleless', require);
11
11
  const bp = Import.lazy('./build-platform', require);
12
+ const copyUtils = Import.lazy('../../utils/copy', require);
12
13
  export const checkPlatformAndRunBuild = async (platform, options) => {
13
14
  const {
14
15
  api,
@@ -80,9 +81,10 @@ export const build = async (api, config) => {
80
81
  clear = true,
81
82
  isTsProject
82
83
  } = config;
84
+ const appContext = api.useAppContext();
83
85
  const {
84
86
  appDirectory
85
- } = api.useAppContext();
87
+ } = appContext;
86
88
  const modernConfig = api.useResolvedConfigContext();
87
89
  const {
88
90
  output: {
@@ -110,6 +112,10 @@ export const build = async (api, config) => {
110
112
  api,
111
113
  deps
112
114
  });
115
+ await copyUtils.copyTask({
116
+ modernConfig,
117
+ appContext
118
+ });
113
119
 
114
120
  if (config.enableWatchMode) {
115
121
  console.info(chalk.blue.underline('start build in watch mode...\n'));
@@ -1,11 +1,14 @@
1
- import { createParallelWorkflow } from '@modern-js/plugin';
1
+ import { createParallelWorkflow, createAsyncWorkflow } from '@modern-js/plugin';
2
2
  import { registerHook } from '@modern-js/core';
3
3
  export const moduleToolsMenu = createParallelWorkflow();
4
+ export const afterDev = createAsyncWorkflow();
4
5
  export const devHooks = {
5
- moduleToolsMenu
6
+ moduleToolsMenu,
7
+ afterDev
6
8
  };
7
9
  export const lifecycle = () => {
8
10
  registerHook({
9
- moduleToolsMenu
11
+ moduleToolsMenu,
12
+ afterDev
10
13
  });
11
14
  };
@@ -13,7 +13,10 @@ const commands = _utils.Import.lazy('../commands', require);
13
13
 
14
14
  const devCli = (program, api) => {
15
15
  program.command('dev [subCmd]').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async (subCmd, params) => {
16
- await commands.dev(api, params, subCmd);
16
+ await commands.dev(api, params, subCmd); // support plugin-proxy
17
+
18
+ const runner = api.useHookRunners();
19
+ await runner.afterDev();
17
20
  });
18
21
  };
19
22
 
@@ -42,8 +42,6 @@ const watchAssets = (api, {
42
42
  targetDir,
43
43
  outputDir
44
44
  }) => {
45
- const appContext = api.useAppContext();
46
- const modernConfig = api.useResolvedConfigContext();
47
45
  (0, _utils.watch)(`${targetDir}/**/*.*`, async ({
48
46
  changeType,
49
47
  changedFilePath
@@ -59,11 +57,6 @@ const watchAssets = (api, {
59
57
  const file = path.relative(targetDir, changedFilePath);
60
58
 
61
59
  _utils.fs.copyFileSync(changedFilePath, path.resolve(outputDir, file));
62
-
63
- await copyUtils.copyTask({
64
- modernConfig,
65
- appContext
66
- });
67
60
  }, ['**/*.{js,jsx,ts,tsx,d.ts,scss,less,css,sass}']);
68
61
  };
69
62
 
@@ -56,6 +56,11 @@ const generatorTsConfig = (projectTsconfig, {
56
56
  include,
57
57
  exclude
58
58
  };
59
+
60
+ if (projectTsconfig.extends) {
61
+ resetConfig.extends = projectTsconfig.extends.startsWith('.') ? path.join(resolvePath, projectTsconfig.extends) : projectTsconfig.extends;
62
+ }
63
+
59
64
  const recommendOption = {
60
65
  // Ensure that Babel can safely transpile files in the TypeScript project
61
66
  compilerOptions: {
@@ -29,6 +29,8 @@ const bundleless = _utils.Import.lazy('./bundleless', require);
29
29
 
30
30
  const bp = _utils.Import.lazy('./build-platform', require);
31
31
 
32
+ const copyUtils = _utils.Import.lazy('../../utils/copy', require);
33
+
32
34
  const checkPlatformAndRunBuild = async (platform, options) => {
33
35
  const {
34
36
  api,
@@ -111,9 +113,10 @@ const build = async (api, config) => {
111
113
  clear = true,
112
114
  isTsProject
113
115
  } = config;
116
+ const appContext = api.useAppContext();
114
117
  const {
115
118
  appDirectory
116
- } = api.useAppContext();
119
+ } = appContext;
117
120
  const modernConfig = api.useResolvedConfigContext();
118
121
  const {
119
122
  output: {
@@ -141,6 +144,10 @@ const build = async (api, config) => {
141
144
  api,
142
145
  deps
143
146
  });
147
+ await copyUtils.copyTask({
148
+ modernConfig,
149
+ appContext
150
+ });
144
151
 
145
152
  if (config.enableWatchMode) {
146
153
  console.info(_utils.chalk.blue.underline('start build in watch mode...\n'));
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.moduleToolsMenu = exports.lifecycle = exports.devHooks = void 0;
6
+ exports.moduleToolsMenu = exports.lifecycle = exports.devHooks = exports.afterDev = void 0;
7
7
 
8
8
  var _plugin = require("@modern-js/plugin");
9
9
 
@@ -11,14 +11,18 @@ var _core = require("@modern-js/core");
11
11
 
12
12
  const moduleToolsMenu = (0, _plugin.createParallelWorkflow)();
13
13
  exports.moduleToolsMenu = moduleToolsMenu;
14
+ const afterDev = (0, _plugin.createAsyncWorkflow)();
15
+ exports.afterDev = afterDev;
14
16
  const devHooks = {
15
- moduleToolsMenu
17
+ moduleToolsMenu,
18
+ afterDev
16
19
  };
17
20
  exports.devHooks = devHooks;
18
21
 
19
22
  const lifecycle = () => {
20
23
  (0, _core.registerHook)({
21
- moduleToolsMenu
24
+ moduleToolsMenu,
25
+ afterDev
22
26
  });
23
27
  };
24
28
 
@@ -3,12 +3,14 @@ export declare const moduleToolsMenu: import("@modern-js/plugin").ParallelWorkfl
3
3
  value: string;
4
4
  runTask: (p: any) => void | Promise<void>;
5
5
  }>;
6
+ export declare const afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
6
7
  export declare const devHooks: {
7
8
  moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
8
9
  name: string;
9
10
  value: string;
10
11
  runTask: (p: any) => void | Promise<void>;
11
12
  }>;
13
+ afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
12
14
  };
13
15
  export declare const lifecycle: () => void;
14
16
  declare module '@modern-js/core' {
@@ -10,6 +10,7 @@ export declare const hooks: {
10
10
  value: string;
11
11
  runTask: (p: any) => void | Promise<void>;
12
12
  }>;
13
+ afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
13
14
  platformBuild: import("@modern-js/plugin").ParallelWorkflow<import("./build").PlatformBuildOption, {
14
15
  name: string;
15
16
  title: string;
@@ -11,6 +11,7 @@ export interface ITsconfig {
11
11
  } | undefined;
12
12
  include?: string[];
13
13
  exclude?: string[];
14
+ extends?: string;
14
15
  }
15
16
  export declare const readTsConfig: <T extends ITsconfig | null>(tsconfigPath: string, noExistReturn?: T) => ITsconfig | T;
16
17
  export declare const existTsConfigFile: (tsconfigAbsolutePath: string) => boolean;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.19.0",
14
+ "version": "1.20.1",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },
@@ -54,18 +54,18 @@
54
54
  "@babel/runtime": "^7.18.0",
55
55
  "@babel/traverse": "^7.18.0",
56
56
  "@babel/types": "^7.18.0",
57
- "@modern-js/babel-compiler": "1.19.0",
58
- "@modern-js/babel-preset-module": "1.19.0",
59
- "@modern-js/core": "1.19.0",
60
- "@modern-js/css-config": "1.19.0",
61
- "@modern-js/new-action": "1.19.0",
62
- "@modern-js/upgrade": "1.19.0",
63
- "@modern-js/plugin": "1.19.0",
64
- "@modern-js/plugin-changeset": "1.19.0",
65
- "@modern-js/plugin-i18n": "1.19.0",
66
- "@modern-js/plugin-jarvis": "1.19.0",
67
- "@modern-js/style-compiler": "1.19.0",
68
- "@modern-js/utils": "1.19.0",
57
+ "@modern-js/babel-compiler": "1.20.1",
58
+ "@modern-js/babel-preset-module": "1.20.1",
59
+ "@modern-js/core": "1.20.1",
60
+ "@modern-js/css-config": "1.20.1",
61
+ "@modern-js/new-action": "1.20.1",
62
+ "@modern-js/upgrade": "1.20.1",
63
+ "@modern-js/plugin": "1.20.1",
64
+ "@modern-js/plugin-changeset": "1.20.1",
65
+ "@modern-js/plugin-i18n": "1.20.1",
66
+ "@modern-js/plugin-jarvis": "1.20.1",
67
+ "@modern-js/style-compiler": "1.20.1",
68
+ "@modern-js/utils": "1.20.1",
69
69
  "@rollup/plugin-json": "~4.1.0",
70
70
  "@speedy-js/speedy-types": "0.13.2-modern.1",
71
71
  "@speedy-js/speedy-core": "0.13.2-modern.1",
@@ -79,8 +79,8 @@
79
79
  "signal-exit": "^3.0.7"
80
80
  },
81
81
  "devDependencies": {
82
- "@scripts/build": "1.19.0",
83
- "@scripts/jest-config": "1.19.0",
82
+ "@scripts/build": "1.20.1",
83
+ "@scripts/jest-config": "1.20.1",
84
84
  "@types/babel__core": "^7.1.15",
85
85
  "@types/babel__generator": "^7.6.3",
86
86
  "@types/babel__traverse": "^7.14.2",