@modern-js/module-tools 1.1.4-beta.0 → 1.2.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 +46 -0
- package/dist/js/modern/tasks/build-source-code.js +2 -1
- package/dist/js/modern/tasks/build-watch-source-code.js +9 -1
- package/dist/js/node/tasks/build-source-code.js +2 -1
- package/dist/js/node/tasks/build-watch-source-code.js +9 -1
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/jest.config.js +8 -0
- package/package.json +30 -21
- package/src/cli/dev.ts +1 -1
- package/src/commands/build.ts +1 -1
- package/src/tasks/build-source-code.ts +1 -0
- package/src/tasks/build-watch-source-code.ts +1 -1
- package/src/tasks/generator-dts.ts +1 -1
- package/tests/fixtures/tspaths/a.ts +1 -0
- package/tests/fixtures/tspaths/b.ts +1 -0
- package/tests/index.test.ts +7 -0
- package/tests/tspaths-transform.test.ts +21 -0
- package/tsconfig.json +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cfe11628: Make Modern.js self bootstraping
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [2da09c69]
|
|
12
|
+
- Updated dependencies [fc71e36f]
|
|
13
|
+
- Updated dependencies [2c049918]
|
|
14
|
+
- Updated dependencies [c3d46ee4]
|
|
15
|
+
- Updated dependencies [cfe11628]
|
|
16
|
+
- Updated dependencies [1ebc7ee2]
|
|
17
|
+
- Updated dependencies [146dcd85]
|
|
18
|
+
- Updated dependencies [1ebc7ee2]
|
|
19
|
+
- @modern-js/utils@1.2.0
|
|
20
|
+
- @modern-js/core@1.3.0
|
|
21
|
+
- @modern-js/new-action@1.3.0
|
|
22
|
+
- @modern-js/babel-preset-module@1.2.0
|
|
23
|
+
- @modern-js/css-config@1.2.0
|
|
24
|
+
- @modern-js/i18n-cli-language-detector@1.2.0
|
|
25
|
+
- @modern-js/plugin-analyze@1.2.0
|
|
26
|
+
- @modern-js/plugin-changeset@1.2.0
|
|
27
|
+
- @modern-js/plugin-fast-refresh@1.2.0
|
|
28
|
+
- @modern-js/plugin-i18n@1.2.0
|
|
29
|
+
- @modern-js/babel-compiler@1.2.0
|
|
30
|
+
- @modern-js/style-compiler@1.2.0
|
|
31
|
+
- @modern-js/module-tools-hooks@1.2.0
|
|
32
|
+
|
|
33
|
+
## 1.1.5
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 2da27d3b: fix sourcemap 'source' config
|
|
38
|
+
- Updated dependencies [5e3de7d8]
|
|
39
|
+
- Updated dependencies [2da27d3b]
|
|
40
|
+
- Updated dependencies [4819a3c7]
|
|
41
|
+
- Updated dependencies [b7fb82ec]
|
|
42
|
+
- Updated dependencies [81d93503]
|
|
43
|
+
- @modern-js/plugin-i18n@1.1.2
|
|
44
|
+
- @modern-js/babel-compiler@1.1.4
|
|
45
|
+
- @modern-js/new-action@1.2.2
|
|
46
|
+
- @modern-js/plugin-changeset@1.1.2
|
|
47
|
+
- @modern-js/utils@1.1.6
|
|
48
|
+
|
|
3
49
|
## 1.1.4
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -63,7 +63,8 @@ export const getWillCompilerCode = (srcDirOrFile, option) => {
|
|
|
63
63
|
const exts = getExts(isTsProject);
|
|
64
64
|
const globPattern = `${srcDirOrFile}/**/*{${exts.join(',')}}`;
|
|
65
65
|
const files = glob.sync(globPattern, {
|
|
66
|
-
ignore: [`${srcDirOrFile}/**/*.d.ts`]
|
|
66
|
+
ignore: [`${srcDirOrFile}/**/*.d.ts`],
|
|
67
|
+
absolute: true
|
|
67
68
|
});
|
|
68
69
|
return files;
|
|
69
70
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
|
|
1
7
|
import { Import, fs } from '@modern-js/utils';
|
|
2
8
|
import { initEnv } from "../utils/init-env";
|
|
3
9
|
const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
|
|
@@ -61,7 +67,9 @@ const runBabelCompiler = async (config, modernConfig) => {
|
|
|
61
67
|
distDir: config.distDir,
|
|
62
68
|
watchDir: config.srcRootDir,
|
|
63
69
|
extensions: getExts(isTs)
|
|
64
|
-
}, babelConfig)
|
|
70
|
+
}, _objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
71
|
+
sourceMaps: config.sourceMaps
|
|
72
|
+
}));
|
|
65
73
|
emitter.on(babelCompiler.BuildWatchEvent.compiling, () => {
|
|
66
74
|
console.info(logger.clearFlag, `Compiling...`);
|
|
67
75
|
});
|
|
@@ -79,7 +79,8 @@ const getWillCompilerCode = (srcDirOrFile, option) => {
|
|
|
79
79
|
const exts = getExts(isTsProject);
|
|
80
80
|
const globPattern = `${srcDirOrFile}/**/*{${exts.join(',')}}`;
|
|
81
81
|
const files = glob.sync(globPattern, {
|
|
82
|
-
ignore: [`${srcDirOrFile}/**/*.d.ts`]
|
|
82
|
+
ignore: [`${srcDirOrFile}/**/*.d.ts`],
|
|
83
|
+
absolute: true
|
|
83
84
|
});
|
|
84
85
|
return files;
|
|
85
86
|
};
|
|
@@ -4,6 +4,12 @@ var _utils = require("@modern-js/utils");
|
|
|
4
4
|
|
|
5
5
|
var _initEnv = require("../utils/init-env");
|
|
6
6
|
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
7
13
|
const babelCompiler = _utils.Import.lazy('@modern-js/babel-compiler', require);
|
|
8
14
|
|
|
9
15
|
const logger = _utils.Import.lazy('../features/build/logger', require);
|
|
@@ -73,7 +79,9 @@ const runBabelCompiler = async (config, modernConfig) => {
|
|
|
73
79
|
distDir: config.distDir,
|
|
74
80
|
watchDir: config.srcRootDir,
|
|
75
81
|
extensions: getExts(isTs)
|
|
76
|
-
}, babelConfig)
|
|
82
|
+
}, _objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
83
|
+
sourceMaps: config.sourceMaps
|
|
84
|
+
}));
|
|
77
85
|
emitter.on(babelCompiler.BuildWatchEvent.compiling, () => {
|
|
78
86
|
console.info(logger.clearFlag, `Compiling...`);
|
|
79
87
|
});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const defineConfig: (config: import("@modern-js/core/config").ConfigParam) => import("@modern-js/core/config").ConfigParam;
|
|
1
|
+
export declare const defineConfig: (config: import("@modern-js/core/src/config").ConfigParam) => import("@modern-js/core/src/config").ConfigParam;
|
|
2
2
|
|
|
3
3
|
declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
|
|
4
4
|
config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.2.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -23,13 +23,20 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"node": {
|
|
26
|
+
"jsnext:source": "./src/index.ts",
|
|
26
27
|
"import": "./dist/js/modern/index.js",
|
|
27
28
|
"require": "./dist/js/node/index.js"
|
|
28
29
|
},
|
|
29
30
|
"default": "./dist/js/treeshaking/index.js"
|
|
30
31
|
},
|
|
31
|
-
"./cli":
|
|
32
|
-
|
|
32
|
+
"./cli": {
|
|
33
|
+
"jsnext:source": "./src/index.ts",
|
|
34
|
+
"default": "./dist/js/node/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./build": {
|
|
37
|
+
"jsnext:source": "./src/build.ts",
|
|
38
|
+
"default": "./dist/js/node/build.js"
|
|
39
|
+
}
|
|
33
40
|
},
|
|
34
41
|
"typesVersions": {
|
|
35
42
|
"*": {
|
|
@@ -44,19 +51,19 @@
|
|
|
44
51
|
"@babel/runtime": "^7",
|
|
45
52
|
"@babel/traverse": "^7.15.0",
|
|
46
53
|
"@babel/types": "^7.15.0",
|
|
47
|
-
"@modern-js/babel-compiler": "^1.
|
|
48
|
-
"@modern-js/babel-preset-module": "^1.
|
|
49
|
-
"@modern-js/core": "^1.
|
|
50
|
-
"@modern-js/css-config": "^1.
|
|
51
|
-
"@modern-js/i18n-cli-language-detector": "^1.
|
|
52
|
-
"@modern-js/module-tools-hooks": "^1.
|
|
53
|
-
"@modern-js/new-action": "^1.
|
|
54
|
-
"@modern-js/plugin-analyze": "^1.
|
|
55
|
-
"@modern-js/plugin-changeset": "^1.
|
|
56
|
-
"@modern-js/plugin-fast-refresh": "^1.
|
|
57
|
-
"@modern-js/plugin-i18n": "^1.
|
|
58
|
-
"@modern-js/style-compiler": "^1.
|
|
59
|
-
"@modern-js/utils": "^1.
|
|
54
|
+
"@modern-js/babel-compiler": "^1.2.0",
|
|
55
|
+
"@modern-js/babel-preset-module": "^1.2.0",
|
|
56
|
+
"@modern-js/core": "^1.3.0",
|
|
57
|
+
"@modern-js/css-config": "^1.2.0",
|
|
58
|
+
"@modern-js/i18n-cli-language-detector": "^1.2.0",
|
|
59
|
+
"@modern-js/module-tools-hooks": "^1.2.0",
|
|
60
|
+
"@modern-js/new-action": "^1.3.0",
|
|
61
|
+
"@modern-js/plugin-analyze": "^1.2.0",
|
|
62
|
+
"@modern-js/plugin-changeset": "^1.2.0",
|
|
63
|
+
"@modern-js/plugin-fast-refresh": "^1.2.0",
|
|
64
|
+
"@modern-js/plugin-i18n": "^1.2.0",
|
|
65
|
+
"@modern-js/style-compiler": "^1.2.0",
|
|
66
|
+
"@modern-js/utils": "^1.2.0",
|
|
60
67
|
"chalk": "^4.1.2",
|
|
61
68
|
"chokidar": "^3.5.2",
|
|
62
69
|
"dotenv": "^10.0.0",
|
|
@@ -75,7 +82,7 @@
|
|
|
75
82
|
},
|
|
76
83
|
"devDependencies": {
|
|
77
84
|
"@babel/preset-typescript": "^7.15.0",
|
|
78
|
-
"@modern-js/babel-chain": "^1.
|
|
85
|
+
"@modern-js/babel-chain": "^1.2.0",
|
|
79
86
|
"@types/babel__core": "^7.1.15",
|
|
80
87
|
"@types/babel__generator": "^7.6.3",
|
|
81
88
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -88,8 +95,9 @@
|
|
|
88
95
|
"@types/signale": "^1.4.2",
|
|
89
96
|
"commander": "^8.1.0",
|
|
90
97
|
"typescript": "^4",
|
|
91
|
-
"@
|
|
92
|
-
"
|
|
98
|
+
"@scripts/build": "0.0.0",
|
|
99
|
+
"jest": "^27",
|
|
100
|
+
"@scripts/jest-config": "0.0.0"
|
|
93
101
|
},
|
|
94
102
|
"sideEffects": false,
|
|
95
103
|
"modernConfig": {
|
|
@@ -99,12 +107,13 @@
|
|
|
99
107
|
},
|
|
100
108
|
"publishConfig": {
|
|
101
109
|
"registry": "https://registry.npmjs.org/",
|
|
102
|
-
"access": "public"
|
|
110
|
+
"access": "public",
|
|
111
|
+
"types": "./dist/types/index.d.ts"
|
|
103
112
|
},
|
|
104
113
|
"scripts": {
|
|
105
114
|
"new": "modern new",
|
|
106
115
|
"build": "modern build",
|
|
107
|
-
"test": "
|
|
116
|
+
"test": "jest --passWithNoTests"
|
|
108
117
|
},
|
|
109
118
|
"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"
|
|
110
119
|
}
|
package/src/cli/dev.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Import } from '@modern-js/utils';
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
|
-
import type { IDevOption } from '
|
|
3
|
+
import type { IDevOption } from '../commands/dev';
|
|
4
4
|
|
|
5
5
|
const local: typeof import('../locale') = Import.lazy('../locale', require);
|
|
6
6
|
const commands: typeof import('../commands') = Import.lazy(
|
package/src/commands/build.ts
CHANGED
|
@@ -82,7 +82,7 @@ const runBabelCompiler = async (
|
|
|
82
82
|
watchDir: config.srcRootDir,
|
|
83
83
|
extensions: getExts(isTs),
|
|
84
84
|
},
|
|
85
|
-
babelConfig,
|
|
85
|
+
{ ...babelConfig, sourceMaps: config.sourceMaps },
|
|
86
86
|
);
|
|
87
87
|
emitter.on(babelCompiler.BuildWatchEvent.compiling, () => {
|
|
88
88
|
console.info(logger.clearFlag, `Compiling...`);
|
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import * as os from 'os';
|
|
4
4
|
import { Import, fs } from '@modern-js/utils';
|
|
5
5
|
import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
|
|
6
|
-
import type { ITsconfig } from '
|
|
6
|
+
import type { ITsconfig } from '../types';
|
|
7
7
|
|
|
8
8
|
const tsPathsTransform: typeof import('../utils/tspaths-transform') =
|
|
9
9
|
Import.lazy('../utils/tspaths-transform', require);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@/b.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const b = 10;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { transformDtsAlias } from '../src/utils/tspaths-transform';
|
|
3
|
+
|
|
4
|
+
describe('tspaths-transform', () => {
|
|
5
|
+
it('transformDtsAlias', () => {
|
|
6
|
+
const filepath = path.join(__dirname, 'fixtures/tspaths/a.ts');
|
|
7
|
+
const options = {
|
|
8
|
+
filenames: [filepath],
|
|
9
|
+
baseUrl: './',
|
|
10
|
+
paths: {
|
|
11
|
+
'@/*': ['./*'],
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
expect(transformDtsAlias(options)).toEqual([
|
|
15
|
+
{
|
|
16
|
+
path: filepath,
|
|
17
|
+
content: "import '@/b.ts';",
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
});
|