@modern-js/module-tools 1.4.3 → 1.4.6

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 (55) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/js/modern/features/build/build-platform.js +1 -2
  3. package/dist/js/modern/features/build/build-watch.js +1 -2
  4. package/dist/js/modern/features/build/build.js +2 -5
  5. package/dist/js/modern/features/dev/index.js +1 -2
  6. package/dist/js/modern/hooks/build.js +20 -0
  7. package/dist/js/modern/hooks/dev.js +11 -0
  8. package/dist/js/modern/hooks/index.js +14 -0
  9. package/dist/js/modern/index.js +1 -1
  10. package/dist/js/modern/tasks/build-source-code.js +1 -2
  11. package/dist/js/modern/tasks/build-style.js +2 -3
  12. package/dist/js/modern/tasks/build-watch-style.js +3 -6
  13. package/dist/js/modern/tasks/copy-assets.js +1 -2
  14. package/dist/js/modern/tasks/generator-dts/index.js +8 -11
  15. package/dist/js/modern/tasks/generator-dts/utils.js +11 -3
  16. package/dist/js/modern/utils/babel.js +2 -19
  17. package/dist/js/modern/utils/copy.js +1 -2
  18. package/dist/js/modern/utils/logger.js +1 -2
  19. package/dist/js/node/features/build/build-platform.js +2 -3
  20. package/dist/js/node/features/build/build-watch.js +1 -3
  21. package/dist/js/node/features/build/build.js +1 -6
  22. package/dist/js/node/features/dev/index.js +2 -6
  23. package/dist/js/node/hooks/build.js +37 -0
  24. package/dist/js/node/hooks/dev.js +25 -0
  25. package/dist/js/node/hooks/index.js +39 -0
  26. package/dist/js/node/index.js +2 -2
  27. package/dist/js/node/tasks/build-source-code.js +3 -3
  28. package/dist/js/node/tasks/build-style.js +2 -4
  29. package/dist/js/node/tasks/build-watch-style.js +3 -7
  30. package/dist/js/node/tasks/copy-assets.js +1 -3
  31. package/dist/js/node/tasks/generator-dts/index.js +8 -16
  32. package/dist/js/node/tasks/generator-dts/utils.js +18 -8
  33. package/dist/js/node/utils/babel.js +1 -18
  34. package/dist/js/node/utils/copy.js +1 -2
  35. package/dist/js/node/utils/logger.js +5 -7
  36. package/dist/types/cli/build.d.ts +1 -1
  37. package/dist/types/cli/dev.d.ts +1 -1
  38. package/dist/types/cli/new.d.ts +1 -1
  39. package/dist/types/hooks/build.d.ts +46 -0
  40. package/dist/types/hooks/dev.d.ts +18 -0
  41. package/dist/types/hooks/index.d.ts +26 -0
  42. package/dist/types/tasks/generator-dts/utils.d.ts +2 -1
  43. package/dist/types/utils/babel.d.ts +2 -3
  44. package/jest.config.js +0 -3
  45. package/package.json +22 -25
  46. package/tests/dev-cli.test.ts +0 -59
  47. package/tests/dev-command.test.ts +0 -70
  48. package/tests/dev-feature.test.ts +0 -78
  49. package/tests/fixtures/tspaths/a.ts +0 -1
  50. package/tests/fixtures/tspaths/b.ts +0 -1
  51. package/tests/generator-dts-utils.test.ts +0 -10
  52. package/tests/generator-dts.test.ts +0 -48
  53. package/tests/index.test.ts +0 -7
  54. package/tests/tsconfig.json +0 -11
  55. package/tests/tspaths-transform.test.ts +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
8
+ - 60f7d8bf: feat: add tests dir to npmignore
9
+ - 3bf4f8b0: feat: support start api server only
10
+ - 305e0bb4: fix: commander.commandsMap typing not work
11
+ - Updated dependencies [a4330c73]
12
+ - Updated dependencies [b8599d09]
13
+ - Updated dependencies [6cffe99d]
14
+ - Updated dependencies [04ae5262]
15
+ - Updated dependencies [60f7d8bf]
16
+ - Updated dependencies [e4cec1ce]
17
+ - Updated dependencies [3b7aa8bb]
18
+ - Updated dependencies [5dbbeb57]
19
+ - Updated dependencies [ebfcbb35]
20
+ - Updated dependencies [3bf4f8b0]
21
+ - Updated dependencies [305e0bb4]
22
+ - Updated dependencies [ebfcbb35]
23
+ - @modern-js/core@1.8.0
24
+ - @modern-js/utils@1.5.0
25
+ - @modern-js/babel-preset-module@1.3.2
26
+ - @modern-js/css-config@1.2.4
27
+ - @modern-js/i18n-cli-language-detector@1.2.2
28
+ - @modern-js/plugin-changeset@1.2.5
29
+ - @modern-js/plugin-fast-refresh@1.2.4
30
+ - @modern-js/plugin-i18n@1.2.4
31
+ - @modern-js/new-action@1.3.6
32
+ - @modern-js/babel-compiler@1.2.3
33
+ - @modern-js/style-compiler@1.2.4
34
+ - @modern-js/plugin@1.3.3
35
+ - @modern-js/plugin-analyze@1.4.0
36
+
37
+ ## 1.4.5
38
+
39
+ ### Patch Changes
40
+
41
+ - 07a4887e: feat: prebundle commander and signale to @modern-js/utils
42
+ - 17d0cc46: feat: prebundle lodash to @modern-js/utils/lodash
43
+ - Updated dependencies [60855eb2]
44
+ - Updated dependencies [046e58aa]
45
+ - Updated dependencies [ec1b7367]
46
+ - Updated dependencies [77ff9754]
47
+ - Updated dependencies [d2d1d6b2]
48
+ - Updated dependencies [07a4887e]
49
+ - Updated dependencies [ea2ae711]
50
+ - Updated dependencies [17d0cc46]
51
+ - Updated dependencies [d2d1d6b2]
52
+ - @modern-js/core@1.7.0
53
+ - @modern-js/plugin-analyze@1.3.6
54
+ - @modern-js/utils@1.4.0
55
+ - @modern-js/plugin-i18n@1.2.3
56
+ - @modern-js/new-action@1.3.5
57
+ - @modern-js/style-compiler@1.2.3
58
+ - @modern-js/css-config@1.2.3
59
+ - @modern-js/plugin-changeset@1.2.4
60
+ - @modern-js/plugin-fast-refresh@1.2.3
61
+
62
+ ## 1.4.4
63
+
64
+ ### Patch Changes
65
+
66
+ - 12b4dd41: fix: throw error when tsc is not installed
67
+ - 132f7b53: feat: move config declarations to @modern-js/core
68
+ - 8491b6dd: fix: optimise "types" exports from plugin
69
+ - 133a5dd7: remove module hooks dep
70
+ - 9d4a005b: fix: config babel via tools.babel
71
+ - Updated dependencies [bebb39b6]
72
+ - Updated dependencies [ef28a4e6]
73
+ - Updated dependencies [132f7b53]
74
+ - Updated dependencies [ff73a5cc]
75
+ - Updated dependencies [9d4a005b]
76
+ - @modern-js/css-config@1.2.3
77
+ - @modern-js/plugin-analyze@1.3.5
78
+ - @modern-js/plugin-changeset@1.2.4
79
+ - @modern-js/plugin-fast-refresh@1.2.3
80
+ - @modern-js/core@1.6.1
81
+ - @modern-js/utils@1.3.7
82
+
3
83
  ## 1.4.3
4
84
 
5
85
  ### Patch Changes
@@ -4,8 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import { Import, chalk } from '@modern-js/utils';
8
- const execa = Import.lazy('execa', require);
7
+ import { execa, Import, chalk } from '@modern-js/utils';
9
8
  const lg = Import.lazy('./logger', require);
10
9
  const pMap = Import.lazy('p-map', require);
11
10
  export const buildPlatform = async (api, option) => {
@@ -1,7 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import * as os from 'os';
3
- import { Import } from '@modern-js/utils';
4
- const execa = Import.lazy('execa', require);
3
+ import { execa, Import } from '@modern-js/utils';
5
4
  const lg = Import.lazy('./logger', require);
6
5
  const pMap = Import.lazy('p-map', require);
7
6
  const utils = Import.lazy('./utils', require);
@@ -1,10 +1,8 @@
1
- /* eslint-disable max-statements */
2
1
  import * as path from 'path';
3
2
  import * as os from 'os';
4
- import { Import } from '@modern-js/utils';
3
+ import { execa, Import } from '@modern-js/utils';
5
4
  const pMap = Import.lazy('p-map', require);
6
5
  const utils = Import.lazy('./utils', require);
7
- const execa = Import.lazy('execa', require);
8
6
  const lg = Import.lazy('./logger', require);
9
7
  const constants = Import.lazy('./constants', require);
10
8
  export const buildSourceCode = async (api, config, _) => {
@@ -105,5 +103,4 @@ export const buildSourceCode = async (api, config, _) => {
105
103
  // eslint-disable-next-line no-process-exit
106
104
  process.exit(1);
107
105
  }
108
- };
109
- /* eslint-enable max-statements */
106
+ };
@@ -1,5 +1,4 @@
1
- import { Import } from '@modern-js/utils';
2
- import chalk from 'chalk';
1
+ import { chalk, Import } from '@modern-js/utils';
3
2
  const inquirer = Import.lazy('inquirer', require);
4
3
  const color = Import.lazy('../../utils/color', require);
5
4
  export const showMenu = async (api, config) => {
@@ -0,0 +1,20 @@
1
+ import { createParallelWorkflow, createAsyncPipeline } from '@modern-js/plugin';
2
+ import { registerHook } from '@modern-js/core';
3
+ export const platformBuild = createParallelWorkflow();
4
+ export const moduleLessConfig = createAsyncPipeline();
5
+ export const moduleSassConfig = createAsyncPipeline();
6
+ export const moduleTailwindConfig = createAsyncPipeline();
7
+ export const buildHooks = {
8
+ platformBuild,
9
+ moduleLessConfig,
10
+ moduleSassConfig,
11
+ moduleTailwindConfig
12
+ };
13
+ export const lifecycle = () => {
14
+ registerHook({
15
+ moduleLessConfig,
16
+ moduleSassConfig,
17
+ moduleTailwindConfig,
18
+ platformBuild
19
+ });
20
+ };
@@ -0,0 +1,11 @@
1
+ import { createParallelWorkflow } from '@modern-js/plugin';
2
+ import { registerHook } from '@modern-js/core';
3
+ export const moduleToolsMenu = createParallelWorkflow();
4
+ export const devHooks = {
5
+ moduleToolsMenu
6
+ };
7
+ export const lifecycle = () => {
8
+ registerHook({
9
+ moduleToolsMenu
10
+ });
11
+ };
@@ -0,0 +1,14 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import { buildHooks, lifecycle as buildLifeCycle } from "./build";
8
+ import { devHooks, lifecycle as devLifeCycle } from "./dev";
9
+ export { buildLifeCycle, devLifeCycle };
10
+ export const lifecycle = () => {
11
+ devLifeCycle();
12
+ buildLifeCycle();
13
+ };
14
+ export const hooks = _objectSpread(_objectSpread({}, buildHooks), devHooks);
@@ -1,7 +1,7 @@
1
1
  import { Import } from '@modern-js/utils';
2
2
  import ChangesetPlugin from '@modern-js/plugin-changeset';
3
3
  import AnalyzePlugin from '@modern-js/plugin-analyze';
4
- import { hooks } from '@modern-js/module-tools-hooks';
4
+ import { hooks } from "./hooks";
5
5
  const cli = Import.lazy('./cli', require);
6
6
  const local = Import.lazy('./locale', require);
7
7
  const schema = Import.lazy('./schema', require);
@@ -4,10 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import { Import, fs } from '@modern-js/utils';
7
+ import { Import, glob, fs } from '@modern-js/utils';
8
8
  import { initEnv } from "../utils/init-env";
9
9
  const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
10
- const glob = Import.lazy('glob', require);
11
10
  const argv = Import.lazy('process.argv', require);
12
11
  const core = Import.lazy('@modern-js/core', require);
13
12
  const bc = Import.lazy('../utils/babel', require);
@@ -1,10 +1,9 @@
1
1
  import * as path from 'path';
2
- import { fs, Import } from '@modern-js/utils';
2
+ import { fs, glob, Import } from '@modern-js/utils';
3
3
  const cssConfig = Import.lazy('@modern-js/css-config', require);
4
4
  const core = Import.lazy('@modern-js/core', require);
5
5
  const compiler = Import.lazy('@modern-js/style-compiler', require);
6
- const glob = Import.lazy('glob', require);
7
- const hooks = Import.lazy('@modern-js/module-tools-hooks', require);
6
+ const hooks = Import.lazy('../hooks', require);
8
7
  const STYLE_DIRS = 'styles';
9
8
  const SRC_STYLE_DIRS = 'src';
10
9
 
@@ -1,12 +1,10 @@
1
- /* eslint-disable max-statements */
2
1
  import * as path from 'path';
3
- import { fs, watch, WatchChangeType, Import } from '@modern-js/utils';
2
+ import { fs, glob, watch, WatchChangeType, Import } from '@modern-js/utils';
4
3
  const logger = Import.lazy('../features/build/logger', require);
5
4
  const cssConfig = Import.lazy('@modern-js/css-config', require);
6
- const hooks = Import.lazy('@modern-js/module-tools-hooks', require);
5
+ const hooks = Import.lazy('../hooks', require);
7
6
  const core = Import.lazy('@modern-js/core', require);
8
7
  const compiler = Import.lazy('@modern-js/style-compiler', require);
9
- const glob = Import.lazy('glob', require);
10
8
  const STYLE_DIRS = 'styles';
11
9
  const SRC_STYLE_DIRS = 'src';
12
10
 
@@ -214,5 +212,4 @@ const taskMain = async ({
214
212
  console.error(e);
215
213
  }
216
214
  });
217
- })();
218
- /* eslint-enable max-statements */
215
+ })();
@@ -1,7 +1,6 @@
1
1
  import * as path from 'path';
2
- import { fs, watch, WatchChangeType, Import } from '@modern-js/utils';
2
+ import { fs, watch, glob, WatchChangeType, Import } from '@modern-js/utils';
3
3
  const argv = Import.lazy('process.argv', require);
4
- const glob = Import.lazy('glob', require);
5
4
  const core = Import.lazy('@modern-js/core', require);
6
5
  const copyUtils = Import.lazy('../utils/copy', require);
7
6
  const STYLE_DIRS = 'styles';
@@ -1,7 +1,6 @@
1
- import * as path from 'path';
2
- import { Import, fs } from '@modern-js/utils';
1
+ import { Import, execa, fs, isObject } from '@modern-js/utils';
2
+ import { getTscBinPath } from "./utils";
3
3
  const core = Import.lazy('@modern-js/core', require);
4
- const execa = Import.lazy('execa', require);
5
4
  const JSON5 = Import.lazy('json5', require);
6
5
  const argv = Import.lazy('process.argv', require);
7
6
  const utils = Import.lazy('./utils', require);
@@ -62,7 +61,7 @@ const generatorDts = async (_, config) => {
62
61
  sourceDir: sourceDirName
63
62
  });
64
63
  removeTsconfigPath = willDeleteTsconfigPath;
65
- const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
64
+ const tscBinFile = getTscBinPath(appDirectory);
66
65
  const watchParams = watch ? ['-w'] : [];
67
66
  const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
68
67
  stdio: 'pipe',
@@ -75,17 +74,15 @@ const generatorDts = async (_, config) => {
75
74
 
76
75
  try {
77
76
  await childProgress;
78
- console.info('[Tsc Compiler]: Successfully');
77
+ console.info('[TSC Compiler]: Successfully');
79
78
  } catch (e) {
80
79
  if (!tsCheck) {
81
80
  console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
81
+ } // 通过使用 execa,可以将 tsc 的 data 类型的报错信息变为异常错误信息
82
+ else if (isObject(e) && e.stdout) {
83
+ console.error(e.stdout);
82
84
  } else {
83
- const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
84
-
85
-
86
- if (isRecord(e)) {
87
- console.error(e.stdout);
88
- }
85
+ console.error(e);
89
86
  }
90
87
  }
91
88
 
@@ -5,12 +5,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import * as path from 'path';
8
- import { Import, fs } from '@modern-js/utils';
9
- const glob = Import.lazy('glob', require);
8
+ import { Import, glob, fs } from '@modern-js/utils';
9
+ import { merge as deepMerge } from '@modern-js/utils/lodash';
10
10
  const babel = Import.lazy('../../utils/babel', require);
11
11
  const tsPathsTransform = Import.lazy('../../utils/tspaths-transform', require);
12
12
  const constants = Import.lazy('../constants', require);
13
- const deepMerge = Import.lazy('lodash.merge', require);
14
13
  export const generatorTsConfig = (projectTsconfig, {
15
14
  appDirectory,
16
15
  distDir,
@@ -79,4 +78,13 @@ export const resolveAlias = (modernConfig, config, watchFilenames = []) => {
79
78
  for (const r of result) {
80
79
  fs.writeFileSync(r.path, r.content);
81
80
  }
81
+ };
82
+ export const getTscBinPath = appDirectory => {
83
+ const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
84
+
85
+ if (!fs.existsSync(tscBinFile)) {
86
+ throw new Error('Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.');
87
+ }
88
+
89
+ return tscBinFile;
82
90
  };
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import { getBabelConfig, getModuleBabelChain } from '@modern-js/babel-preset-module';
7
+ import { getBabelConfig } from '@modern-js/babel-preset-module';
8
8
  import { applyOptionsChain, getAlias, isUseSSRBundle } from '@modern-js/utils';
9
9
  export const getFinalAlias = (modernConfig, option) => {
10
10
  const aliasConfig = getAlias(modernConfig.source.alias, option); // 排除内部别名,因为不需要处理
@@ -72,23 +72,6 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option) => {
72
72
  }); // Preventing warning when files are too large
73
73
 
74
74
  internalBabelConfig.compact = false;
75
- const babelChain = getModuleBabelChain({
76
- appDirectory,
77
- enableReactPreset: true,
78
- enableTypescriptPreset: true,
79
- alias: aliasConfig,
80
- envVars,
81
- globalVars,
82
- lodashOptions,
83
- jsxTransformRuntime,
84
- importStyle
85
- }, {
86
- type: option.type,
87
- syntax: option.syntax
88
- });
89
75
  const userBabelConfig = modernConfig.tools.babel;
90
- return applyOptionsChain(internalBabelConfig, // TODO: 感觉 userBabelConfig 的类型应该是TransformOptions
91
- userBabelConfig, {
92
- chain: babelChain
93
- });
76
+ return applyOptionsChain(internalBabelConfig, userBabelConfig);
94
77
  };
@@ -8,8 +8,7 @@ import * as path from 'path';
8
8
  import { fs, Import } from '@modern-js/utils';
9
9
  const globby = Import.lazy('globby', require);
10
10
  const fastGlob = Import.lazy('fast-glob', require);
11
- const normalizePath = Import.lazy('normalize-path', require); // eslint-disable-next-line max-statements
12
-
11
+ const normalizePath = Import.lazy('normalize-path', require);
13
12
  export const copyTask = async option => {
14
13
  const {
15
14
  modernConfig,
@@ -1,6 +1,5 @@
1
1
  import EventEmitter from 'events';
2
- import { Import } from '@modern-js/utils';
3
- const chalk = Import.lazy('chalk', require);
2
+ import { chalk } from '@modern-js/utils';
4
3
  export const clearFlag = '\x1Bc';
5
4
  export const logTemplate = (title, messageStack, maxLength, {
6
5
  noBottomBorder: _noBottomBorder = false,
@@ -13,8 +13,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
13
 
14
14
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
15
 
16
- const execa = _utils.Import.lazy('execa', require);
17
-
18
16
  const lg = _utils.Import.lazy('./logger', require);
19
17
 
20
18
  const pMap = _utils.Import.lazy('p-map', require);
@@ -58,7 +56,7 @@ const buildPlatform = async (api, option) => {
58
56
  params,
59
57
  logger: _
60
58
  }) => {
61
- const childProcess = execa.node(taskPath, params, {
59
+ const childProcess = _utils.execa.node(taskPath, params, {
62
60
  stdio: 'inherit',
63
61
  all: true
64
62
  }); // lm.addStdout(logger, childProcess.stdout, {
@@ -66,6 +64,7 @@ const buildPlatform = async (api, option) => {
66
64
  // });
67
65
  // lm.addStderr(logger, childProcess.stderr);
68
66
 
67
+
69
68
  try {
70
69
  await childProcess;
71
70
  } catch (_unused) {
@@ -15,8 +15,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
- const execa = _utils.Import.lazy('execa', require);
19
-
20
18
  const lg = _utils.Import.lazy('./logger', require);
21
19
 
22
20
  const pMap = _utils.Import.lazy('p-map', require);
@@ -75,7 +73,7 @@ const buildInWatchMode = async (api, config, _) => {
75
73
  taskPath,
76
74
  params
77
75
  }) => {
78
- const childProcess = execa.node(taskPath, params, {
76
+ const childProcess = _utils.execa.node(taskPath, params, {
79
77
  stdio: 'pipe'
80
78
  });
81
79
 
@@ -15,13 +15,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
- /* eslint-disable max-statements */
19
18
  const pMap = _utils.Import.lazy('p-map', require);
20
19
 
21
20
  const utils = _utils.Import.lazy('./utils', require);
22
21
 
23
- const execa = _utils.Import.lazy('execa', require);
24
-
25
22
  const lg = _utils.Import.lazy('./logger', require);
26
23
 
27
24
  const constants = _utils.Import.lazy('./constants', require);
@@ -70,7 +67,7 @@ const buildSourceCode = async (api, config, _) => {
70
67
  taskPath,
71
68
  params
72
69
  }) => {
73
- const childProcess = execa.node(taskPath, params, {
70
+ const childProcess = _utils.execa.node(taskPath, params, {
74
71
  stdio: 'pipe'
75
72
  });
76
73
 
@@ -125,7 +122,5 @@ const buildSourceCode = async (api, config, _) => {
125
122
  process.exit(1);
126
123
  }
127
124
  };
128
- /* eslint-enable max-statements */
129
-
130
125
 
131
126
  exports.buildSourceCode = buildSourceCode;
@@ -7,10 +7,6 @@ exports.showMenu = exports.runSubCmd = exports.devStorybook = void 0;
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
- var _chalk = _interopRequireDefault(require("chalk"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const inquirer = _utils.Import.lazy('inquirer', require);
15
11
 
16
12
  const color = _utils.Import.lazy('../../utils/color', require);
@@ -20,7 +16,7 @@ const showMenu = async (api, config) => {
20
16
  const metas = await runners.moduleToolsMenu(undefined);
21
17
 
22
18
  if (metas.length <= 0) {
23
- console.info(_chalk.default.yellow('No runnable development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
19
+ console.info(_utils.chalk.yellow('No runnable development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
24
20
 
25
21
  process.exit(0);
26
22
  }
@@ -51,7 +47,7 @@ const devStorybook = async (api, config) => {
51
47
  if (findStorybook) {
52
48
  await findStorybook.runTask(config);
53
49
  } else {
54
- console.info(_chalk.default.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
50
+ console.info(_utils.chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
55
51
 
56
52
  process.exit(0);
57
53
  }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.platformBuild = exports.moduleTailwindConfig = exports.moduleSassConfig = exports.moduleLessConfig = exports.lifecycle = exports.buildHooks = void 0;
7
+
8
+ var _plugin = require("@modern-js/plugin");
9
+
10
+ var _core = require("@modern-js/core");
11
+
12
+ const platformBuild = (0, _plugin.createParallelWorkflow)();
13
+ exports.platformBuild = platformBuild;
14
+ const moduleLessConfig = (0, _plugin.createAsyncPipeline)();
15
+ exports.moduleLessConfig = moduleLessConfig;
16
+ const moduleSassConfig = (0, _plugin.createAsyncPipeline)();
17
+ exports.moduleSassConfig = moduleSassConfig;
18
+ const moduleTailwindConfig = (0, _plugin.createAsyncPipeline)();
19
+ exports.moduleTailwindConfig = moduleTailwindConfig;
20
+ const buildHooks = {
21
+ platformBuild,
22
+ moduleLessConfig,
23
+ moduleSassConfig,
24
+ moduleTailwindConfig
25
+ };
26
+ exports.buildHooks = buildHooks;
27
+
28
+ const lifecycle = () => {
29
+ (0, _core.registerHook)({
30
+ moduleLessConfig,
31
+ moduleSassConfig,
32
+ moduleTailwindConfig,
33
+ platformBuild
34
+ });
35
+ };
36
+
37
+ exports.lifecycle = lifecycle;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.moduleToolsMenu = exports.lifecycle = exports.devHooks = void 0;
7
+
8
+ var _plugin = require("@modern-js/plugin");
9
+
10
+ var _core = require("@modern-js/core");
11
+
12
+ const moduleToolsMenu = (0, _plugin.createParallelWorkflow)();
13
+ exports.moduleToolsMenu = moduleToolsMenu;
14
+ const devHooks = {
15
+ moduleToolsMenu
16
+ };
17
+ exports.devHooks = devHooks;
18
+
19
+ const lifecycle = () => {
20
+ (0, _core.registerHook)({
21
+ moduleToolsMenu
22
+ });
23
+ };
24
+
25
+ exports.lifecycle = lifecycle;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "buildLifeCycle", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _build.lifecycle;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "devLifeCycle", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _dev.lifecycle;
16
+ }
17
+ });
18
+ exports.lifecycle = exports.hooks = void 0;
19
+
20
+ var _build = require("./build");
21
+
22
+ var _dev = require("./dev");
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ const lifecycle = () => {
31
+ (0, _dev.lifecycle)();
32
+ (0, _build.lifecycle)();
33
+ };
34
+
35
+ exports.lifecycle = lifecycle;
36
+
37
+ const hooks = _objectSpread(_objectSpread({}, _build.buildHooks), _dev.devHooks);
38
+
39
+ exports.hooks = hooks;
@@ -17,7 +17,7 @@ var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changes
17
17
 
18
18
  var _pluginAnalyze = _interopRequireDefault(require("@modern-js/plugin-analyze"));
19
19
 
20
- var _moduleToolsHooks = require("@modern-js/module-tools-hooks");
20
+ var _hooks = require("./hooks");
21
21
 
22
22
  var _core = require("@modern-js/core");
23
23
 
@@ -34,7 +34,7 @@ const lang = _utils.Import.lazy('./utils/language', require);
34
34
  var _default = () => ({
35
35
  name: '@modern-js/module-tools',
36
36
  post: ['@modern-js/plugin-analyze', '@modern-js/plugin-changeset'],
37
- registerHook: _moduleToolsHooks.hooks,
37
+ registerHook: _hooks.hooks,
38
38
  usePlugins: [(0, _pluginChangeset.default)(), (0, _pluginAnalyze.default)()],
39
39
  setup: api => {
40
40
  const locale = lang.getLocaleLanguage();
@@ -17,8 +17,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17
17
 
18
18
  const babelCompiler = _utils.Import.lazy('@modern-js/babel-compiler', require);
19
19
 
20
- const glob = _utils.Import.lazy('glob', require);
21
-
22
20
  const argv = _utils.Import.lazy('process.argv', require);
23
21
 
24
22
  const core = _utils.Import.lazy('@modern-js/core', require);
@@ -79,10 +77,12 @@ const getWillCompilerCode = (srcDirOrFile, option) => {
79
77
 
80
78
  const exts = getExts(isTsProject);
81
79
  const globPattern = `${srcDirOrFile}/**/*{${exts.join(',')}}`;
82
- const files = glob.sync(globPattern, {
80
+
81
+ const files = _utils.glob.sync(globPattern, {
83
82
  ignore: [`${srcDirOrFile}/**/*.d.ts`],
84
83
  absolute: true
85
84
  });
85
+
86
86
  return files;
87
87
  };
88
88
 
@@ -14,9 +14,7 @@ const core = _utils.Import.lazy('@modern-js/core', require);
14
14
 
15
15
  const compiler = _utils.Import.lazy('@modern-js/style-compiler', require);
16
16
 
17
- const glob = _utils.Import.lazy('glob', require);
18
-
19
- const hooks = _utils.Import.lazy('@modern-js/module-tools-hooks', require);
17
+ const hooks = _utils.Import.lazy('../hooks', require);
20
18
 
21
19
  const STYLE_DIRS = 'styles';
22
20
  const SRC_STYLE_DIRS = 'src';
@@ -61,7 +59,7 @@ const copyOriginStyleFiles = ({
61
59
  targetDir,
62
60
  outputDir
63
61
  }) => {
64
- const styleFiles = glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
62
+ const styleFiles = _utils.glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
65
63
 
66
64
  if (styleFiles.length > 0) {
67
65
  _utils.fs.ensureDirSync(outputDir);