@modern-js/module-tools 1.4.6 → 1.5.2

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 (32) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/js/modern/commands/build.js +1 -2
  3. package/dist/js/modern/commands/dev.js +1 -2
  4. package/dist/js/modern/features/build/logger/logText.js +8 -3
  5. package/dist/js/modern/features/build/logger/loggerManager.js +7 -2
  6. package/dist/js/modern/features/build/utils.js +6 -2
  7. package/dist/js/modern/features/dev/index.js +1 -2
  8. package/dist/js/modern/tasks/build-style.js +3 -3
  9. package/dist/js/modern/tasks/generator-dts/index.js +2 -3
  10. package/dist/js/modern/utils/copy.js +2 -4
  11. package/dist/js/modern/utils/logger.js +6 -2
  12. package/dist/js/modern/utils/tsconfig.js +1 -2
  13. package/dist/js/modern/utils/tspaths-transform/index.js +2 -2
  14. package/dist/js/node/commands/build.js +3 -3
  15. package/dist/js/node/commands/dev.js +3 -3
  16. package/dist/js/node/features/build/logger/logText.js +8 -3
  17. package/dist/js/node/features/build/logger/loggerManager.js +7 -2
  18. package/dist/js/node/features/build/utils.js +6 -2
  19. package/dist/js/node/features/dev/index.js +1 -3
  20. package/dist/js/node/tasks/build-style.js +3 -3
  21. package/dist/js/node/tasks/generator-dts/index.js +1 -3
  22. package/dist/js/node/utils/copy.js +3 -7
  23. package/dist/js/node/utils/logger.js +6 -2
  24. package/dist/js/node/utils/tsconfig.js +1 -3
  25. package/dist/js/node/utils/tspaths-transform/index.js +2 -2
  26. package/dist/types/features/dev/index.d.ts +1 -1
  27. package/dist/types/utils/tspaths-transform/index.d.ts +2 -2
  28. package/package.json +40 -24
  29. package/.eslintrc.js +0 -10
  30. package/jest.config.js +0 -7
  31. package/modern.config.js +0 -6
  32. package/tsconfig.json +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
8
+ - Updated dependencies [d5913bd96]
9
+ - Updated dependencies [d32f35134]
10
+ - Updated dependencies [43d9bb5fa]
11
+ - Updated dependencies [d9d398e16]
12
+ - Updated dependencies [6ae4a34ae]
13
+ - Updated dependencies [b80229c79]
14
+ - Updated dependencies [948cc4436]
15
+ - @modern-js/plugin@1.3.4
16
+ - @modern-js/babel-preset-module@1.3.5
17
+ - @modern-js/core@1.10.2
18
+ - @modern-js/css-config@1.2.6
19
+ - @modern-js/i18n-cli-language-detector@1.2.3
20
+ - @modern-js/plugin-analyze@1.4.3
21
+ - @modern-js/plugin-changeset@1.2.7
22
+ - @modern-js/plugin-fast-refresh@1.2.6
23
+ - @modern-js/plugin-i18n@1.2.6
24
+ - @modern-js/new-action@1.3.9
25
+ - @modern-js/babel-compiler@1.2.5
26
+ - @modern-js/style-compiler@1.2.6
27
+ - @modern-js/utils@1.7.3
28
+
29
+ ## 1.5.1
30
+
31
+ ### Patch Changes
32
+
33
+ - 69a728375: fix: remove exports.jsnext:source after publish
34
+ - Updated dependencies [cd7346b0d]
35
+ - Updated dependencies [0e0537005]
36
+ - Updated dependencies [6b0bb5e3b]
37
+ - Updated dependencies [69a728375]
38
+ - @modern-js/utils@1.7.2
39
+ - @modern-js/babel-preset-module@1.3.4
40
+ - @modern-js/babel-compiler@1.2.4
41
+ - @modern-js/new-action@1.3.8
42
+ - @modern-js/core@1.10.1
43
+ - @modern-js/css-config@1.2.5
44
+ - @modern-js/plugin-analyze@1.4.2
45
+ - @modern-js/plugin-changeset@1.2.6
46
+ - @modern-js/plugin-fast-refresh@1.2.5
47
+ - @modern-js/plugin-i18n@1.2.5
48
+ - @modern-js/style-compiler@1.2.5
49
+
50
+ ## 1.5.0
51
+
52
+ ### Minor Changes
53
+
54
+ - 0b26b93b: feat: prebundle all dependencies of @modern-js/core
55
+
56
+ ### Patch Changes
57
+
58
+ - 592edabc: feat: prebundle url-join,mime-types,json5,fast-glob,globby,ora,inquirer
59
+ - 895fa0ff: chore: using "workspace:\*" in devDependencies
60
+ - Updated dependencies [2d155c4c]
61
+ - Updated dependencies [123e432d]
62
+ - Updated dependencies [e5a9b26d]
63
+ - Updated dependencies [0b26b93b]
64
+ - Updated dependencies [123e432d]
65
+ - Updated dependencies [f9f66ef9]
66
+ - Updated dependencies [592edabc]
67
+ - Updated dependencies [f9f66ef9]
68
+ - Updated dependencies [895fa0ff]
69
+ - Updated dependencies [3578913e]
70
+ - Updated dependencies [1c3beab3]
71
+ - @modern-js/utils@1.6.0
72
+ - @modern-js/core@1.9.0
73
+ - @modern-js/plugin-analyze@1.4.1
74
+ - @modern-js/new-action@1.3.7
75
+ - @modern-js/babel-preset-module@1.3.3
76
+ - @modern-js/css-config@1.2.4
77
+ - @modern-js/plugin-changeset@1.2.5
78
+ - @modern-js/plugin-fast-refresh@1.2.4
79
+
3
80
  ## 1.4.6
4
81
 
5
82
  ### Patch Changes
@@ -1,9 +1,8 @@
1
1
  import * as path from 'path';
2
- import { fs, Import } from '@modern-js/utils';
2
+ import { fs, Import, dotenv } from '@modern-js/utils';
3
3
  const tsConfigutils = Import.lazy('../utils/tsconfig', require);
4
4
  const valid = Import.lazy('../utils/valide', require);
5
5
  const buildFeature = Import.lazy('../features/build', require);
6
- const dotenv = Import.lazy('dotenv', require);
7
6
  export const build = async (api, {
8
7
  watch: _watch = false,
9
8
  tsconfig: tsconfigName,
@@ -1,7 +1,6 @@
1
1
  import * as path from 'path';
2
- import { Import } from '@modern-js/utils';
2
+ import { dotenv, Import } from '@modern-js/utils';
3
3
  const devFeature = Import.lazy('../features/dev', require);
4
- const dotenv = Import.lazy('dotenv', require);
5
4
  const tsConfigutils = Import.lazy('../utils/tsconfig', require);
6
5
  const valid = Import.lazy('../utils/valide', require);
7
6
 
@@ -1,3 +1,5 @@
1
+ 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; }
2
+
1
3
  import { chalk } from '@modern-js/utils';
2
4
  export const colors = {
3
5
  title: chalk.rgb(218, 152, 92)
@@ -27,9 +29,12 @@ ${_contentColor(messageFragments.join(''))}${_noBottomBorder ? '' : `\n${_bottom
27
29
  // 处理Log内容如何展示
28
30
  export class LoggerText {
29
31
  constructor(option) {
30
- this.messages = void 0;
31
- this.hasErrorMessage = void 0;
32
- this.option = void 0;
32
+ _defineProperty(this, "messages", void 0);
33
+
34
+ _defineProperty(this, "hasErrorMessage", void 0);
35
+
36
+ _defineProperty(this, "option", void 0);
37
+
33
38
  this.messages = [];
34
39
  this.option = option;
35
40
  this.hasErrorMessage = false;
@@ -1,6 +1,8 @@
1
1
  let _ = t => t,
2
2
  _t;
3
3
 
4
+ 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; }
5
+
4
6
  /**
5
7
  * 1. 注册构建任务
6
8
  * 2. 监听各个构建任务进程中的信息:process.stdout.on('data' | 'error')
@@ -13,8 +15,11 @@ const readline = Import.lazy('../../../utils/readline', require);
13
15
  export class LoggerManager extends EventEmitter {
14
16
  constructor() {
15
17
  super();
16
- this._compilering = void 0;
17
- this._listeners = void 0;
18
+
19
+ _defineProperty(this, "_compilering", void 0);
20
+
21
+ _defineProperty(this, "_listeners", void 0);
22
+
18
23
  this._compilering = false;
19
24
  this._listeners = [];
20
25
  }
@@ -1,3 +1,5 @@
1
+ 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; }
2
+
1
3
  import * as path from 'path';
2
4
  import * as os from 'os';
3
5
  import { Import, chalk } from '@modern-js/utils';
@@ -128,7 +130,8 @@ export const getDtsMapper = (api, config, logger) => {
128
130
 
129
131
  export class LogStack {
130
132
  constructor() {
131
- this._codeLogStack = void 0;
133
+ _defineProperty(this, "_codeLogStack", void 0);
134
+
132
135
  this._codeLogStack = [];
133
136
  }
134
137
 
@@ -187,4 +190,5 @@ export class TimeCounter {
187
190
  }
188
191
 
189
192
  }
190
- TimeCounter._now = void 0;
193
+
194
+ _defineProperty(TimeCounter, "_now", void 0);
@@ -1,5 +1,4 @@
1
- import { chalk, Import } from '@modern-js/utils';
2
- const inquirer = Import.lazy('inquirer', require);
1
+ import { chalk, Import, inquirer } from '@modern-js/utils';
3
2
  const color = Import.lazy('../../utils/color', require);
4
3
  export const showMenu = async (api, config) => {
5
4
  const runners = api.useHookRunners();
@@ -118,13 +118,13 @@ const taskMain = async ({
118
118
 
119
119
 
120
120
  const srcDir = path.resolve(appDirectory, SRC_STYLE_DIRS);
121
- const outputDirtoSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
121
+ const outputDirToSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
122
122
 
123
123
  if (importStyle === 'compiled-code') {
124
124
  const srcStyleResult = await compiler.styleCompiler({
125
125
  projectDir: appDirectory,
126
126
  stylesDir: srcDir,
127
- outDir: outputDirtoSrc,
127
+ outDir: outputDirToSrc,
128
128
  enableVirtualDist: true,
129
129
  compilerOption: {
130
130
  less: lessOption,
@@ -136,7 +136,7 @@ const taskMain = async ({
136
136
  } else {
137
137
  copyOriginStyleFiles({
138
138
  targetDir: srcDir,
139
- outputDir: outputDirtoSrc
139
+ outputDir: outputDirToSrc
140
140
  });
141
141
  }
142
142
  };
@@ -1,7 +1,6 @@
1
- import { Import, execa, fs, isObject } from '@modern-js/utils';
1
+ import { Import, execa, fs, json5, isObject } from '@modern-js/utils';
2
2
  import { getTscBinPath } from "./utils";
3
3
  const core = Import.lazy('@modern-js/core', require);
4
- const JSON5 = Import.lazy('json5', require);
5
4
  const argv = Import.lazy('process.argv', require);
6
5
  const utils = Import.lazy('./utils', require);
7
6
  let removeTsconfigPath = '';
@@ -11,7 +10,7 @@ const getProjectTsconfig = tsconfigPath => {
11
10
  return {};
12
11
  }
13
12
 
14
- return JSON5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
13
+ return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
15
14
  };
16
15
 
17
16
  const resolveLog = (childProgress, {
@@ -5,9 +5,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
7
  import * as path from 'path';
8
- import { fs, Import } from '@modern-js/utils';
9
- const globby = Import.lazy('globby', require);
10
- const fastGlob = Import.lazy('fast-glob', require);
8
+ import { fs, Import, globby, fastGlob } from '@modern-js/utils';
11
9
  const normalizePath = Import.lazy('normalize-path', require);
12
10
  export const copyTask = async option => {
13
11
  const {
@@ -33,7 +31,7 @@ export const copyTask = async option => {
33
31
  try {
34
32
  // 类型暂时这样处理,待之后优化copy的逻辑
35
33
  for (const copyOption of copy) {
36
- // 在原来的基础上,引入了类似于 copy-webpck-plugin 的 context 属性,可以设置项目根路径
34
+ // 在原来的基础上,引入了类似于 copy-webpack-plugin 的 context 属性,可以设置项目根路径
37
35
  const {
38
36
  context = appDirectory,
39
37
  from,
@@ -1,3 +1,5 @@
1
+ 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; }
2
+
1
3
  import EventEmitter from 'events';
2
4
  import { chalk } from '@modern-js/utils';
3
5
  export const clearFlag = '\x1Bc';
@@ -25,8 +27,10 @@ ${_contentColor(messageFragments.join(''))}${_noBottomBorder ? '' : `\n${_bottom
25
27
  };
26
28
  export class LoggerText {
27
29
  constructor(option) {
28
- this.messages = void 0;
29
- this.option = void 0;
30
+ _defineProperty(this, "messages", void 0);
31
+
32
+ _defineProperty(this, "option", void 0);
33
+
30
34
  this.messages = [];
31
35
  this.option = option;
32
36
  }
@@ -1,5 +1,4 @@
1
- import { fs, Import } from '@modern-js/utils';
2
- const json5 = Import.lazy('json5', require);
1
+ import { fs, json5 } from '@modern-js/utils';
3
2
  export const readTsConfig = (tsconfigPath, noExistReturn = null) => {
4
3
  // 如果不存在,则返回 noExistReturn
5
4
  if (!fs.existsSync(tsconfigPath)) {
@@ -75,7 +75,7 @@ const transformExport = option => nodePath => {
75
75
  mapPathString(nodePath.get('source'), option);
76
76
  };
77
77
 
78
- const transfromSingleFileAlias = ({
78
+ const transformSingleFileAlias = ({
79
79
  filename,
80
80
  baseUrl,
81
81
  paths
@@ -118,7 +118,7 @@ export const transformDtsAlias = option => {
118
118
  for (const filename of filenames) {
119
119
  transformResult.push({
120
120
  path: filename,
121
- content: transfromSingleFileAlias({
121
+ content: transformSingleFileAlias({
122
122
  filename,
123
123
  baseUrl,
124
124
  paths
@@ -19,8 +19,6 @@ const valid = _utils.Import.lazy('../utils/valide', require);
19
19
 
20
20
  const buildFeature = _utils.Import.lazy('../features/build', require);
21
21
 
22
- const dotenv = _utils.Import.lazy('dotenv', require);
23
-
24
22
  const build = async (api, {
25
23
  watch: _watch = false,
26
24
  tsconfig: tsconfigName,
@@ -33,7 +31,9 @@ const build = async (api, {
33
31
  } = api.useAppContext();
34
32
  const modernConfig = api.useResolvedConfigContext();
35
33
  const tsconfigPath = path.join(appDirectory, tsconfigName);
36
- dotenv.config();
34
+
35
+ _utils.dotenv.config();
36
+
37
37
  const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
38
38
  const enableTscCompiler = isTsProject && tsc && !modernConfig.output.disableTsChecker;
39
39
  valid.valideBeforeTask({
@@ -15,8 +15,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
15
15
 
16
16
  const devFeature = _utils.Import.lazy('../features/dev', require);
17
17
 
18
- const dotenv = _utils.Import.lazy('dotenv', require);
19
-
20
18
  const tsConfigutils = _utils.Import.lazy('../utils/tsconfig', require);
21
19
 
22
20
  const valid = _utils.Import.lazy('../utils/valide', require);
@@ -33,7 +31,9 @@ const dev = async (api, option, subCmd = '') => {
33
31
  appDirectory
34
32
  } = appContext;
35
33
  const tsconfigPath = path.join(appDirectory, tsconfigName);
36
- dotenv.config();
34
+
35
+ _utils.dotenv.config();
36
+
37
37
  valid.valideBeforeTask({
38
38
  modernConfig,
39
39
  tsconfigPath
@@ -7,6 +7,8 @@ exports.logTemplate = exports.colors = exports.clearFlag = exports.LoggerText =
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
+ 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; }
11
+
10
12
  const colors = {
11
13
  title: _utils.chalk.rgb(218, 152, 92)
12
14
  };
@@ -41,9 +43,12 @@ exports.logTemplate = logTemplate;
41
43
  // 处理Log内容如何展示
42
44
  class LoggerText {
43
45
  constructor(option) {
44
- this.messages = void 0;
45
- this.hasErrorMessage = void 0;
46
- this.option = void 0;
46
+ _defineProperty(this, "messages", void 0);
47
+
48
+ _defineProperty(this, "hasErrorMessage", void 0);
49
+
50
+ _defineProperty(this, "option", void 0);
51
+
47
52
  this.messages = [];
48
53
  this.option = option;
49
54
  this.hasErrorMessage = false;
@@ -14,6 +14,8 @@ let _ = t => t,
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
 
17
+ 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; }
18
+
17
19
  const logText = _utils.Import.lazy('./logText', require);
18
20
 
19
21
  const readline = _utils.Import.lazy('../../../utils/readline', require);
@@ -21,8 +23,11 @@ const readline = _utils.Import.lazy('../../../utils/readline', require);
21
23
  class LoggerManager extends _events.default {
22
24
  constructor() {
23
25
  super();
24
- this._compilering = void 0;
25
- this._listeners = void 0;
26
+
27
+ _defineProperty(this, "_compilering", void 0);
28
+
29
+ _defineProperty(this, "_listeners", void 0);
30
+
26
31
  this._compilering = false;
27
32
  this._listeners = [];
28
33
  }
@@ -15,6 +15,8 @@ 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
+ 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; }
19
+
18
20
  const constants = _utils.Import.lazy('./constants', require); // 硬解字符串返回相应格式的对象
19
21
 
20
22
 
@@ -152,7 +154,8 @@ exports.getDtsMapper = getDtsMapper;
152
154
 
153
155
  class LogStack {
154
156
  constructor() {
155
- this._codeLogStack = void 0;
157
+ _defineProperty(this, "_codeLogStack", void 0);
158
+
156
159
  this._codeLogStack = [];
157
160
  }
158
161
 
@@ -219,4 +222,5 @@ class TimeCounter {
219
222
  }
220
223
 
221
224
  exports.TimeCounter = TimeCounter;
222
- TimeCounter._now = void 0;
225
+
226
+ _defineProperty(TimeCounter, "_now", void 0);
@@ -7,8 +7,6 @@ exports.showMenu = exports.runSubCmd = exports.devStorybook = void 0;
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
- const inquirer = _utils.Import.lazy('inquirer', require);
11
-
12
10
  const color = _utils.Import.lazy('../../utils/color', require);
13
11
 
14
12
  const showMenu = async (api, config) => {
@@ -24,7 +22,7 @@ const showMenu = async (api, config) => {
24
22
  const menuMessage = color.devMenuTitle('Select the debug mode:');
25
23
  const {
26
24
  type
27
- } = await inquirer.prompt([{
25
+ } = await _utils.inquirer.prompt([{
28
26
  name: 'type',
29
27
  message: menuMessage,
30
28
  type: 'list',
@@ -133,13 +133,13 @@ const taskMain = async ({
133
133
 
134
134
 
135
135
  const srcDir = path.resolve(appDirectory, SRC_STYLE_DIRS);
136
- const outputDirtoSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
136
+ const outputDirToSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
137
137
 
138
138
  if (importStyle === 'compiled-code') {
139
139
  const srcStyleResult = await compiler.styleCompiler({
140
140
  projectDir: appDirectory,
141
141
  stylesDir: srcDir,
142
- outDir: outputDirtoSrc,
142
+ outDir: outputDirToSrc,
143
143
  enableVirtualDist: true,
144
144
  compilerOption: {
145
145
  less: lessOption,
@@ -151,7 +151,7 @@ const taskMain = async ({
151
151
  } else {
152
152
  copyOriginStyleFiles({
153
153
  targetDir: srcDir,
154
- outputDir: outputDirtoSrc
154
+ outputDir: outputDirToSrc
155
155
  });
156
156
  }
157
157
  };
@@ -6,8 +6,6 @@ var _utils2 = require("./utils");
6
6
 
7
7
  const core = _utils.Import.lazy('@modern-js/core', require);
8
8
 
9
- const JSON5 = _utils.Import.lazy('json5', require);
10
-
11
9
  const argv = _utils.Import.lazy('process.argv', require);
12
10
 
13
11
  const utils = _utils.Import.lazy('./utils', require);
@@ -19,7 +17,7 @@ const getProjectTsconfig = tsconfigPath => {
19
17
  return {};
20
18
  }
21
19
 
22
- return JSON5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
20
+ return _utils.json5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
23
21
  };
24
22
 
25
23
  const resolveLog = (childProgress, {
@@ -19,10 +19,6 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
19
19
 
20
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
21
 
22
- const globby = _utils.Import.lazy('globby', require);
23
-
24
- const fastGlob = _utils.Import.lazy('fast-glob', require);
25
-
26
22
  const normalizePath = _utils.Import.lazy('normalize-path', require);
27
23
 
28
24
  const copyTask = async option => {
@@ -49,7 +45,7 @@ const copyTask = async option => {
49
45
  try {
50
46
  // 类型暂时这样处理,待之后优化copy的逻辑
51
47
  for (const copyOption of copy) {
52
- // 在原来的基础上,引入了类似于 copy-webpck-plugin 的 context 属性,可以设置项目根路径
48
+ // 在原来的基础上,引入了类似于 copy-webpack-plugin 的 context 属性,可以设置项目根路径
53
49
  const {
54
50
  context = appDirectory,
55
51
  from,
@@ -73,9 +69,9 @@ const copyTask = async option => {
73
69
  options = globOptions;
74
70
  }
75
71
 
76
- glob = path.isAbsolute(fromOrigin) ? fromOrigin : path.posix.join(fastGlob.escapePath(normalizePath(path.resolve(context))), fromOrigin); // 计算 glob,获取目标文件
72
+ glob = path.isAbsolute(fromOrigin) ? fromOrigin : path.posix.join(_utils.fastGlob.escapePath(normalizePath(path.resolve(context))), fromOrigin); // 计算 glob,获取目标文件
77
73
 
78
- const paths = await globby(glob, options);
74
+ const paths = await (0, _utils.globby)(glob, options);
79
75
 
80
76
  if (!paths.length) {
81
77
  return;
@@ -11,6 +11,8 @@ var _utils = require("@modern-js/utils");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
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
+
14
16
  const clearFlag = '\x1Bc';
15
17
  exports.clearFlag = clearFlag;
16
18
 
@@ -41,8 +43,10 @@ exports.logTemplate = logTemplate;
41
43
 
42
44
  class LoggerText {
43
45
  constructor(option) {
44
- this.messages = void 0;
45
- this.option = void 0;
46
+ _defineProperty(this, "messages", void 0);
47
+
48
+ _defineProperty(this, "option", void 0);
49
+
46
50
  this.messages = [];
47
51
  this.option = option;
48
52
  }
@@ -7,8 +7,6 @@ exports.readTsConfig = exports.existTsConfigFile = void 0;
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
- const json5 = _utils.Import.lazy('json5', require);
11
-
12
10
  const readTsConfig = (tsconfigPath, noExistReturn = null) => {
13
11
  // 如果不存在,则返回 noExistReturn
14
12
  if (!_utils.fs.existsSync(tsconfigPath)) {
@@ -17,7 +15,7 @@ const readTsConfig = (tsconfigPath, noExistReturn = null) => {
17
15
 
18
16
  const content = _utils.fs.readFileSync(tsconfigPath, 'utf-8');
19
17
 
20
- return json5.parse(content);
18
+ return _utils.json5.parse(content);
21
19
  };
22
20
 
23
21
  exports.readTsConfig = readTsConfig;
@@ -97,7 +97,7 @@ const transformExport = option => nodePath => {
97
97
  mapPathString(nodePath.get('source'), option);
98
98
  };
99
99
 
100
- const transfromSingleFileAlias = ({
100
+ const transformSingleFileAlias = ({
101
101
  filename,
102
102
  baseUrl,
103
103
  paths
@@ -141,7 +141,7 @@ const transformDtsAlias = option => {
141
141
  for (const filename of filenames) {
142
142
  transformResult.push({
143
143
  path: filename,
144
- content: transfromSingleFileAlias({
144
+ content: transformSingleFileAlias({
145
145
  filename,
146
146
  baseUrl,
147
147
  paths
@@ -3,7 +3,7 @@ export interface IDevConfig {
3
3
  appDirectory: string;
4
4
  isTsProject: boolean;
5
5
  }
6
- export declare type DevTaskType = 'storybook' | 'docsite' | 'unknow';
6
+ export declare type DevTaskType = 'storybook' | 'docsite' | 'unknown';
7
7
  export declare const showMenu: (api: PluginAPI, config: IDevConfig) => Promise<void>;
8
8
  export declare const devStorybook: (api: PluginAPI, config: IDevConfig) => Promise<void>;
9
9
  export declare const runSubCmd: (api: PluginAPI, subCmd: string, config: IDevConfig) => Promise<void>;
@@ -3,12 +3,12 @@ export interface TransformOption {
3
3
  baseUrl: string;
4
4
  paths: Record<string, string[] | string>;
5
5
  }
6
- interface TransformDtsAlaisOption {
6
+ interface TransformDtsAliasOption {
7
7
  filenames?: string[];
8
8
  baseUrl: string;
9
9
  paths: Record<string, string[] | string>;
10
10
  }
11
- export declare const transformDtsAlias: (option: TransformDtsAlaisOption) => {
11
+ export declare const transformDtsAlias: (option: TransformDtsAliasOption) => {
12
12
  path: string;
13
13
  content: string;
14
14
  }[];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.6",
14
+ "version": "1.5.2",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },
@@ -54,24 +54,19 @@
54
54
  "@babel/runtime": "^7",
55
55
  "@babel/traverse": "^7.15.0",
56
56
  "@babel/types": "^7.17.0",
57
- "@modern-js/babel-compiler": "^1.2.3",
58
- "@modern-js/babel-preset-module": "^1.3.2",
59
- "@modern-js/core": "^1.8.0",
60
- "@modern-js/css-config": "^1.2.4",
61
- "@modern-js/i18n-cli-language-detector": "^1.2.2",
62
- "@modern-js/new-action": "^1.3.6",
63
- "@modern-js/plugin": "^1.3.3",
64
- "@modern-js/plugin-analyze": "^1.4.0",
65
- "@modern-js/plugin-changeset": "^1.2.5",
66
- "@modern-js/plugin-fast-refresh": "^1.2.4",
67
- "@modern-js/plugin-i18n": "^1.2.4",
68
- "@modern-js/style-compiler": "^1.2.4",
69
- "@modern-js/utils": "^1.5.0",
70
- "dotenv": "^10.0.0",
71
- "fast-glob": "^3.2.5",
72
- "globby": "^11",
73
- "inquirer": "^8.1.5",
74
- "json5": "^2.2.0",
57
+ "@modern-js/babel-compiler": "^1.2.5",
58
+ "@modern-js/babel-preset-module": "^1.3.5",
59
+ "@modern-js/core": "^1.10.2",
60
+ "@modern-js/css-config": "^1.2.6",
61
+ "@modern-js/i18n-cli-language-detector": "^1.2.3",
62
+ "@modern-js/new-action": "^1.3.9",
63
+ "@modern-js/plugin": "^1.3.4",
64
+ "@modern-js/plugin-analyze": "^1.4.3",
65
+ "@modern-js/plugin-changeset": "^1.2.7",
66
+ "@modern-js/plugin-fast-refresh": "^1.2.6",
67
+ "@modern-js/plugin-i18n": "^1.2.6",
68
+ "@modern-js/style-compiler": "^1.2.6",
69
+ "@modern-js/utils": "^1.7.3",
75
70
  "normalize-path": "^3.0.0",
76
71
  "p-map": "^4",
77
72
  "process.argv": "^0.6.0",
@@ -79,15 +74,14 @@
79
74
  },
80
75
  "devDependencies": {
81
76
  "@babel/preset-typescript": "^7.15.0",
82
- "@modern-js/babel-chain": "^1.2.2",
77
+ "@modern-js/babel-chain": "1.2.3",
83
78
  "@scripts/build": "0.0.0",
84
79
  "@scripts/jest-config": "0.0.0",
85
80
  "@types/babel__core": "^7.1.15",
86
81
  "@types/babel__generator": "^7.6.3",
87
82
  "@types/babel__traverse": "^7.14.2",
88
83
  "@types/glob": "^7.1.4",
89
- "@types/inquirer": "^8.1.1",
90
- "@types/jest": "^26",
84
+ "@types/jest": "^27",
91
85
  "@types/node": "^14",
92
86
  "@types/normalize-path": "^3.0.0",
93
87
  "@types/react": "^17",
@@ -105,10 +99,32 @@
105
99
  "registry": "https://registry.npmjs.org/",
106
100
  "access": "public"
107
101
  },
102
+ "wireit": {
103
+ "build": {
104
+ "command": "modern build",
105
+ "files": [
106
+ "src/**/*",
107
+ "tsconfig.json",
108
+ "package.json"
109
+ ],
110
+ "output": [
111
+ "dist/**/*"
112
+ ]
113
+ },
114
+ "test": {
115
+ "command": "jest --passWithNoTests",
116
+ "files": [
117
+ "src/**/*",
118
+ "tsconfig.json",
119
+ "package.json"
120
+ ],
121
+ "output": []
122
+ }
123
+ },
108
124
  "scripts": {
109
125
  "new": "modern new",
110
- "build": "modern build",
111
- "test": "jest --passWithNoTests"
126
+ "build": "wireit",
127
+ "test": "wireit"
112
128
  },
113
129
  "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"
114
130
  }
package/.eslintrc.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: [
5
- require.resolve('./tsconfig.json'),
6
- require.resolve('./tests/tsconfig.json'),
7
- ],
8
- },
9
- ignorePatterns: ['types.d.ts'],
10
- };
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/modern.config.js DELETED
@@ -1,6 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {
3
- output: {
4
- disableSourceMap: true,
5
- },
6
- };
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {},
9
- "types": ["jest"]
10
- },
11
- "include": ["src"]
12
- }