@modern-js/module-tools 1.1.3 → 1.1.4-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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 10676d31: fix build watch error
8
+
3
9
  ## 1.1.3
4
10
 
5
11
  ### Patch Changes
@@ -5,6 +5,7 @@ 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 { Import, fs } from '@modern-js/utils';
8
+ import { initEnv } from "../utils/init-env";
8
9
  const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
9
10
  const glob = Import.lazy('glob', require);
10
11
  const argv = Import.lazy('process.argv', require);
@@ -113,20 +114,6 @@ const generatorRealFiles = virtualDists => {
113
114
  }
114
115
  };
115
116
 
116
- export const initEnv = ({
117
- syntax,
118
- type
119
- }) => {
120
- if (syntax === 'es6+' && type === 'commonjs') {
121
- return 'CJS_ES6';
122
- } else if (syntax === 'es6+' && type === 'module') {
123
- return 'ESM_ES6';
124
- } else if (syntax === 'es5' && type === 'module') {
125
- return 'ESM_ES5';
126
- }
127
-
128
- return '';
129
- };
130
117
  const defaultConfig = {
131
118
  srcRootDir: `${process.cwd()}/src`,
132
119
  willCompilerDirOrFile: `${process.cwd()}/src`,
@@ -1,5 +1,5 @@
1
1
  import { Import, fs } from '@modern-js/utils';
2
- import { initEnv } from "./build-source-code";
2
+ import { initEnv } from "../utils/init-env";
3
3
  const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
4
4
  const logger = Import.lazy('../features/build/logger', require);
5
5
  const ts = Import.lazy('../utils/tsconfig', require);
@@ -0,0 +1,14 @@
1
+ export const initEnv = ({
2
+ syntax,
3
+ type
4
+ }) => {
5
+ if (syntax === 'es6+' && type === 'commonjs') {
6
+ return 'CJS_ES6';
7
+ } else if (syntax === 'es6+' && type === 'module') {
8
+ return 'ESM_ES6';
9
+ } else if (syntax === 'es5' && type === 'module') {
10
+ return 'ESM_ES5';
11
+ }
12
+
13
+ return '';
14
+ };
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.initEnv = exports.getWillCompilerCode = exports.buildSourceCode = exports.Compiler = void 0;
6
+ exports.getWillCompilerCode = exports.buildSourceCode = exports.Compiler = void 0;
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
+ var _initEnv = require("../utils/init-env");
11
+
10
12
  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; }
11
13
 
12
14
  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; }
@@ -136,22 +138,6 @@ const generatorRealFiles = virtualDists => {
136
138
  }
137
139
  };
138
140
 
139
- const initEnv = ({
140
- syntax,
141
- type
142
- }) => {
143
- if (syntax === 'es6+' && type === 'commonjs') {
144
- return 'CJS_ES6';
145
- } else if (syntax === 'es6+' && type === 'module') {
146
- return 'ESM_ES6';
147
- } else if (syntax === 'es5' && type === 'module') {
148
- return 'ESM_ES5';
149
- }
150
-
151
- return '';
152
- };
153
-
154
- exports.initEnv = initEnv;
155
141
  const defaultConfig = {
156
142
  srcRootDir: `${process.cwd()}/src`,
157
143
  willCompilerDirOrFile: `${process.cwd()}/src`,
@@ -171,7 +157,7 @@ const taskMain = async ({
171
157
  // Execution of the script's parameter handling and related required configuration acquisition
172
158
  const processArgv = argv(process.argv.slice(2));
173
159
  const config = processArgv(defaultConfig);
174
- process.env.BUILD_FORMAT = initEnv(config);
160
+ process.env.BUILD_FORMAT = (0, _initEnv.initEnv)(config);
175
161
  const compiler = Compiler.babel; // Currently, only babel is supported.
176
162
 
177
163
  const babelConfig = bc.resolveBabelConfig(config.appDirectory, modernConfig, {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _utils = require("@modern-js/utils");
4
4
 
5
- var _buildSourceCode = require("./build-source-code");
5
+ var _initEnv = require("../utils/init-env");
6
6
 
7
7
  const babelCompiler = _utils.Import.lazy('@modern-js/babel-compiler', require);
8
8
 
@@ -136,7 +136,7 @@ const taskMain = async ({
136
136
  syntax: 'es5',
137
137
  type: 'module'
138
138
  });
139
- process.env.BUILD_FORMAT = (0, _buildSourceCode.initEnv)(config);
139
+ process.env.BUILD_FORMAT = (0, _initEnv.initEnv)(config);
140
140
  await buildSourceCode(config, modernConfig);
141
141
  };
142
142
 
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initEnv = void 0;
7
+
8
+ const initEnv = ({
9
+ syntax,
10
+ type
11
+ }) => {
12
+ if (syntax === 'es6+' && type === 'commonjs') {
13
+ return 'CJS_ES6';
14
+ } else if (syntax === 'es6+' && type === 'module') {
15
+ return 'ESM_ES6';
16
+ } else if (syntax === 'es5' && type === 'module') {
17
+ return 'ESM_ES5';
18
+ }
19
+
20
+ return '';
21
+ };
22
+
23
+ exports.initEnv = initEnv;
@@ -22,24 +22,4 @@ export declare const getWillCompilerCode: (srcDirOrFile: string, option: {
22
22
  isTsProject: boolean;
23
23
  }) => string[];
24
24
  export declare const buildSourceCode: (config: IBuildSourceCodeConfig) => Promise<import("@modern-js/babel-compiler").ICompilerResult>;
25
- export declare const initEnv: ({
26
- syntax,
27
- type
28
- }: {
29
- syntax: ITaskConfig['syntax'];
30
- type: ITaskConfig['type'];
31
- }) => "" | "CJS_ES6" | "ESM_ES6" | "ESM_ES5";
32
- interface ITaskConfig {
33
- srcRootDir: string;
34
- willCompilerDirOrFile: string;
35
- distDir: string;
36
- appDirectory: string;
37
- sourceMaps: boolean;
38
- syntax: 'es5' | 'es6+';
39
- type: 'module' | 'commonjs';
40
- tsconfigPath: string;
41
- copyDirs?: string;
42
- compiler?: 'babel' | 'esbuild' | 'swc';
43
- watch: boolean;
44
- }
45
25
  export {};
@@ -0,0 +1,21 @@
1
+ interface ITaskConfig {
2
+ srcRootDir: string;
3
+ willCompilerDirOrFile: string;
4
+ distDir: string;
5
+ appDirectory: string;
6
+ sourceMaps: boolean;
7
+ syntax: 'es5' | 'es6+';
8
+ type: 'module' | 'commonjs';
9
+ tsconfigPath: string;
10
+ copyDirs?: string;
11
+ compiler?: 'babel' | 'esbuild' | 'swc';
12
+ watch: boolean;
13
+ }
14
+ export declare const initEnv: ({
15
+ syntax,
16
+ type
17
+ }: {
18
+ syntax: ITaskConfig['syntax'];
19
+ type: ITaskConfig['type'];
20
+ }) => "" | "CJS_ES6" | "ESM_ES6" | "ESM_ES5";
21
+ export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.3",
14
+ "version": "1.1.4-beta.0",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },
@@ -88,8 +88,8 @@
88
88
  "@types/signale": "^1.4.2",
89
89
  "commander": "^8.1.0",
90
90
  "typescript": "^4",
91
- "@modern-js/plugin-testing": "^1.1.1",
92
- "@modern-js/module-tools": "^1.1.2"
91
+ "@modern-js/plugin-testing": "^1.2.0",
92
+ "@modern-js/module-tools": "^1.1.3"
93
93
  },
94
94
  "sideEffects": false,
95
95
  "modernConfig": {
@@ -2,6 +2,7 @@ import { Import, fs } from '@modern-js/utils';
2
2
  import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
3
3
  import type { BabelOptions, IVirtualDist } from '@modern-js/babel-compiler';
4
4
  import type { ITsconfig } from '../types';
5
+ import { initEnv } from '../utils/init-env';
5
6
 
6
7
  const babelCompiler: typeof import('@modern-js/babel-compiler') = Import.lazy(
7
8
  '@modern-js/babel-compiler',
@@ -138,24 +139,6 @@ const generatorRealFiles = (virtualDists: IVirtualDist[]) => {
138
139
  }
139
140
  };
140
141
 
141
- export const initEnv = ({
142
- syntax,
143
- type,
144
- }: {
145
- syntax: ITaskConfig['syntax'];
146
- type: ITaskConfig['type'];
147
- }) => {
148
- if (syntax === 'es6+' && type === 'commonjs') {
149
- return 'CJS_ES6';
150
- } else if (syntax === 'es6+' && type === 'module') {
151
- return 'ESM_ES6';
152
- } else if (syntax === 'es5' && type === 'module') {
153
- return 'ESM_ES5';
154
- }
155
-
156
- return '';
157
- };
158
-
159
142
  interface ITaskConfig {
160
143
  srcRootDir: string; // 源码的根目录
161
144
  willCompilerDirOrFile: string; // 用于编译的源码文件或者源码目录
@@ -2,7 +2,7 @@ import { Import, fs } from '@modern-js/utils';
2
2
  import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
3
3
  import type { ICompilerResult, IVirtualDist } from '@modern-js/babel-compiler';
4
4
  import type { ITsconfig } from '../types';
5
- import { initEnv } from './build-source-code';
5
+ import { initEnv } from '../utils/init-env';
6
6
 
7
7
  const babelCompiler: typeof import('@modern-js/babel-compiler') = Import.lazy(
8
8
  '@modern-js/babel-compiler',
@@ -0,0 +1,31 @@
1
+ interface ITaskConfig {
2
+ srcRootDir: string; // 源码的根目录
3
+ willCompilerDirOrFile: string; // 用于编译的源码文件或者源码目录
4
+ distDir: string;
5
+ appDirectory: string;
6
+ sourceMaps: boolean;
7
+ syntax: 'es5' | 'es6+';
8
+ type: 'module' | 'commonjs';
9
+ tsconfigPath: string;
10
+ copyDirs?: string;
11
+ compiler?: 'babel' | 'esbuild' | 'swc';
12
+ watch: boolean;
13
+ }
14
+
15
+ export const initEnv = ({
16
+ syntax,
17
+ type,
18
+ }: {
19
+ syntax: ITaskConfig['syntax'];
20
+ type: ITaskConfig['type'];
21
+ }) => {
22
+ if (syntax === 'es6+' && type === 'commonjs') {
23
+ return 'CJS_ES6';
24
+ } else if (syntax === 'es6+' && type === 'module') {
25
+ return 'ESM_ES6';
26
+ } else if (syntax === 'es5' && type === 'module') {
27
+ return 'ESM_ES5';
28
+ }
29
+
30
+ return '';
31
+ };