@modern-js/plugin-module-import 2.15.0 → 2.17.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 +26 -0
- package/dist/cjs/index.js +83 -57
- package/dist/esm/index.js +36 -27
- package/package.json +12 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @modern-js/plugin-module-import
|
|
2
2
|
|
|
3
|
+
## 2.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/module-tools@2.17.0
|
|
8
|
+
|
|
9
|
+
## 2.16.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b06f571: feat(plugin-module-import): 移除使用 libuild-plugin-swc 的逻辑,更改为配置 transformImport
|
|
14
|
+
feat(plugin-module-import): Remove the logic for using libuild-plugin-swc and replace it with the configuration transformImport.
|
|
15
|
+
- 4e876ab: chore: package.json include the monorepo-relative directory
|
|
16
|
+
|
|
17
|
+
chore: 在 package.json 中声明 monorepo 的子路径
|
|
18
|
+
|
|
19
|
+
- b06f571: chore: update libuild and libuild plugins version to 0.12.0
|
|
20
|
+
chore: 更新 libuild 和 libuild 插件的版本到 0.12.0
|
|
21
|
+
- Updated dependencies [b06f571]
|
|
22
|
+
- Updated dependencies [acc0a00]
|
|
23
|
+
- Updated dependencies [fd4a8a6]
|
|
24
|
+
- Updated dependencies [4e876ab]
|
|
25
|
+
- Updated dependencies [355d36e]
|
|
26
|
+
- Updated dependencies [b06f571]
|
|
27
|
+
- @modern-js/module-tools@2.16.0
|
|
28
|
+
|
|
3
29
|
## 2.15.0
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,62 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var src_exports = {};
|
|
29
|
-
__export(src_exports, {
|
|
30
|
-
default: () => src_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
const _libuildpluginswc = require("@modern-js/libuild-plugin-swc");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
11
|
+
if (typeof WeakMap !== "function")
|
|
12
|
+
return null;
|
|
13
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
16
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
+
})(nodeInterop);
|
|
18
|
+
}
|
|
19
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
24
|
+
return {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
29
|
+
if (cache && cache.has(obj)) {
|
|
30
|
+
return cache.get(obj);
|
|
31
|
+
}
|
|
32
|
+
var newObj = {};
|
|
33
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
+
for (var key in obj) {
|
|
35
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
36
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
37
|
+
if (desc && (desc.get || desc.set)) {
|
|
38
|
+
Object.defineProperty(newObj, key, desc);
|
|
39
|
+
} else {
|
|
40
|
+
newObj[key] = obj[key];
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
newObj.default = obj;
|
|
45
|
+
if (cache) {
|
|
46
|
+
cache.set(obj, newObj);
|
|
47
|
+
}
|
|
48
|
+
return newObj;
|
|
49
|
+
}
|
|
50
|
+
const _default = (options) => {
|
|
51
|
+
return {
|
|
52
|
+
name: "@modern-js/plugin-module-import",
|
|
53
|
+
setup: () => {
|
|
54
|
+
return {
|
|
55
|
+
beforeBuildTask(config) {
|
|
56
|
+
var _options_pluginImport;
|
|
57
|
+
config.transformImport = (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : [];
|
|
58
|
+
return config;
|
|
59
|
+
},
|
|
60
|
+
async modifyLibuild(config, next) {
|
|
61
|
+
var _config_plugins, _config_plugins1;
|
|
62
|
+
if ((_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.find((p) => p.name === _libuildpluginswc.swcTransformPluginName)) {
|
|
63
|
+
return next(config);
|
|
64
|
+
}
|
|
65
|
+
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
66
|
+
return next(config);
|
|
67
|
+
}
|
|
68
|
+
const { transformPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("@modern-js/libuild-plugin-swc")));
|
|
69
|
+
var _options_pluginImport;
|
|
70
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(transformPlugin({
|
|
71
|
+
jsc: {
|
|
72
|
+
// swc transform jsx to `React.createElement` in default mode.
|
|
73
|
+
transform: {
|
|
74
|
+
react: {
|
|
75
|
+
runtime: config.jsx === "transform" ? "classic" : "automatic"
|
|
76
|
+
}
|
|
49
77
|
}
|
|
78
|
+
},
|
|
79
|
+
extensions: {
|
|
80
|
+
pluginImport: (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : []
|
|
50
81
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
return next(config);
|
|
82
|
+
}));
|
|
83
|
+
return next(config);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
58
86
|
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {});
|
|
87
|
+
};
|
|
88
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { swcTransformPluginName } from "@modern-js/libuild-plugin-swc";
|
|
2
|
+
export default (options) => {
|
|
3
|
+
return {
|
|
4
|
+
name: "@modern-js/plugin-module-import",
|
|
5
|
+
setup: () => {
|
|
6
|
+
return {
|
|
7
|
+
beforeBuildTask(config) {
|
|
8
|
+
var _options_pluginImport;
|
|
9
|
+
config.transformImport = (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : [];
|
|
10
|
+
return config;
|
|
11
|
+
},
|
|
12
|
+
async modifyLibuild(config, next) {
|
|
13
|
+
var _config_plugins, _config_plugins1;
|
|
14
|
+
if ((_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.find((p) => p.name === swcTransformPluginName)) {
|
|
15
|
+
return next(config);
|
|
16
|
+
}
|
|
17
|
+
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
18
|
+
return next(config);
|
|
19
|
+
}
|
|
20
|
+
const { transformPlugin } = await import("@modern-js/libuild-plugin-swc");
|
|
21
|
+
var _options_pluginImport;
|
|
22
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(transformPlugin({
|
|
23
|
+
jsc: {
|
|
24
|
+
// swc transform jsx to `React.createElement` in default mode.
|
|
25
|
+
transform: {
|
|
26
|
+
react: {
|
|
27
|
+
runtime: config.jsx === "transform" ? "classic" : "automatic"
|
|
28
|
+
}
|
|
17
29
|
}
|
|
30
|
+
},
|
|
31
|
+
extensions: {
|
|
32
|
+
pluginImport: (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : []
|
|
18
33
|
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
return next(config);
|
|
34
|
+
}));
|
|
35
|
+
return next(config);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
26
38
|
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
export {
|
|
30
|
-
src_default as default
|
|
39
|
+
};
|
|
31
40
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
"description": "The import plugin of Modern.js Module Tools.",
|
|
4
4
|
"homepage": "https://modernjs.dev/module-tools",
|
|
5
5
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/web-infra-dev/modern.js",
|
|
9
|
+
"directory": "packages/module/plugin-module-import"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"keywords": [
|
|
9
13
|
"react",
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
"modern",
|
|
12
16
|
"modern.js"
|
|
13
17
|
],
|
|
14
|
-
"version": "2.
|
|
18
|
+
"version": "2.17.0",
|
|
15
19
|
"types": "./dist/types/index.d.ts",
|
|
16
20
|
"main": "./dist/cjs/index.js",
|
|
17
21
|
"exports": {
|
|
@@ -25,20 +29,20 @@
|
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@modern-js/libuild-plugin-swc": "~0.
|
|
32
|
+
"@modern-js/libuild-plugin-swc": "~0.12.0"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
35
|
"@types/jest": "^29",
|
|
32
36
|
"@types/node": "^14",
|
|
33
37
|
"typescript": "^4",
|
|
34
38
|
"jest": "^29",
|
|
35
|
-
"@modern-js/libuild": "~0.
|
|
36
|
-
"@scripts/build": "2.
|
|
37
|
-
"@scripts/jest-config": "2.
|
|
38
|
-
"@modern-js/module-tools": "2.
|
|
39
|
+
"@modern-js/libuild": "~0.12.0",
|
|
40
|
+
"@scripts/build": "2.17.0",
|
|
41
|
+
"@scripts/jest-config": "2.17.0",
|
|
42
|
+
"@modern-js/module-tools": "2.17.0"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
41
|
-
"@modern-js/module-tools": "^2.
|
|
45
|
+
"@modern-js/module-tools": "^2.17.0"
|
|
42
46
|
},
|
|
43
47
|
"peerDependenciesMeta": {
|
|
44
48
|
"@modern-js/module-tools": {
|