@modern-js/plugin-module-import 2.27.0 → 2.28.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 +19 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +46 -89
- package/package.json +8 -7
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @modern-js/plugin-module-import
|
|
2
2
|
|
|
3
|
+
## 2.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 118c1c0: chore: upgrade libuild and libuild plugin version to 0.14.1
|
|
8
|
+
chore: 升级 libuild 和 libuild 插件的版本到 0.14.1
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- d3e52e4: chore(CI): update build config to improve vitest CI perf
|
|
13
|
+
|
|
14
|
+
chore(CI): 更新构建配置来提升 vitest CI 性能
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [3092f1f]
|
|
17
|
+
- Updated dependencies [118c1c0]
|
|
18
|
+
- Updated dependencies [b7a8c43]
|
|
19
|
+
- Updated dependencies [d3e52e4]
|
|
20
|
+
- @modern-js/module-tools@2.28.0
|
|
21
|
+
|
|
3
22
|
## 2.27.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { CliPlugin, ModuleTools } from '@modern-js/module-tools';
|
|
2
|
-
import { ImportItem } from '@modern-js/libuild-plugin-swc';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
pluginImport?: ImportItem[];
|
|
1
|
+
import type { CliPlugin, ModuleTools } from '@modern-js/module-tools';
|
|
2
|
+
import type { ImportItem } from '@modern-js/libuild-plugin-swc';
|
|
3
|
+
export declare const modulePluginImport: (options: {
|
|
4
|
+
pluginImport?: ImportItem[];
|
|
6
5
|
}) => CliPlugin<ModuleTools>;
|
|
7
|
-
|
|
8
|
-
export { modulePluginImport as default, modulePluginImport };
|
|
6
|
+
export default modulePluginImport;
|
package/dist/index.js
CHANGED
|
@@ -1,101 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
modulePluginImport: function() {
|
|
14
|
+
return modulePluginImport;
|
|
15
|
+
},
|
|
16
|
+
// deprecated default export
|
|
17
|
+
default: function() {
|
|
18
|
+
return _default;
|
|
16
19
|
}
|
|
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 __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/index.ts
|
|
50
|
-
var src_exports = {};
|
|
51
|
-
__export(src_exports, {
|
|
52
|
-
default: () => src_default,
|
|
53
|
-
modulePluginImport: () => modulePluginImport
|
|
54
20
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
21
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
22
|
+
const _libuildpluginswc = require("@modern-js/libuild-plugin-swc");
|
|
23
|
+
const modulePluginImport = (options) => ({
|
|
58
24
|
name: "@modern-js/plugin-module-import",
|
|
59
25
|
setup: () => ({
|
|
60
26
|
beforeBuildTask(config) {
|
|
61
|
-
var
|
|
62
|
-
config.transformImport = (
|
|
27
|
+
var _options_pluginImport;
|
|
28
|
+
config.transformImport = (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : [];
|
|
63
29
|
return config;
|
|
64
30
|
},
|
|
65
|
-
modifyLibuild(config, next) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if ((_a2 = config.plugins) == null ? void 0 : _a2.find((p) => p.name === import_libuild_plugin_swc.swcTransformPluginName)) {
|
|
69
|
-
return next(config);
|
|
70
|
-
}
|
|
71
|
-
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
72
|
-
return next(config);
|
|
73
|
-
}
|
|
74
|
-
const { transformPlugin } = yield import("@modern-js/libuild-plugin-swc");
|
|
75
|
-
(_c = config.plugins) == null ? void 0 : _c.push(
|
|
76
|
-
transformPlugin({
|
|
77
|
-
jsc: {
|
|
78
|
-
// swc transform jsx to `React.createElement` in default mode.
|
|
79
|
-
transform: {
|
|
80
|
-
react: {
|
|
81
|
-
runtime: config.jsx === "transform" ? "classic" : "automatic"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
extensions: {
|
|
86
|
-
pluginImport: (_b = options.pluginImport) != null ? _b : []
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
);
|
|
31
|
+
async modifyLibuild(config, next) {
|
|
32
|
+
var _config_plugins, _config_plugins1;
|
|
33
|
+
if ((_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.find((p) => p.name === _libuildpluginswc.swcTransformPluginName)) {
|
|
90
34
|
return next(config);
|
|
91
|
-
}
|
|
35
|
+
}
|
|
36
|
+
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
37
|
+
return next(config);
|
|
38
|
+
}
|
|
39
|
+
const { transformPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/libuild-plugin-swc")));
|
|
40
|
+
var _options_pluginImport;
|
|
41
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(transformPlugin({
|
|
42
|
+
jsc: {
|
|
43
|
+
// swc transform jsx to `React.createElement` in default mode.
|
|
44
|
+
transform: {
|
|
45
|
+
react: {
|
|
46
|
+
runtime: config.jsx === "transform" ? "classic" : "automatic"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
extensions: {
|
|
51
|
+
pluginImport: (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : []
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
return next(config);
|
|
92
55
|
}
|
|
93
56
|
})
|
|
94
57
|
});
|
|
95
|
-
|
|
96
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
-
0 && (module.exports = {
|
|
98
|
-
modulePluginImport
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
//# sourceMappingURL=index.js.map
|
|
58
|
+
const _default = modulePluginImport;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.28.0",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@modern-js/libuild-plugin-swc": "0.
|
|
30
|
+
"@modern-js/libuild-plugin-swc": "0.14.1",
|
|
31
31
|
"@swc/helpers": "0.5.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -35,13 +35,14 @@
|
|
|
35
35
|
"@types/node": "^14",
|
|
36
36
|
"typescript": "^5",
|
|
37
37
|
"jest": "^29",
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@scripts/
|
|
41
|
-
"@
|
|
38
|
+
"@swc/helpers": "0.5.1",
|
|
39
|
+
"@modern-js/libuild": "0.14.1",
|
|
40
|
+
"@scripts/build": "2.28.0",
|
|
41
|
+
"@scripts/jest-config": "2.28.0",
|
|
42
|
+
"@modern-js/module-tools": "2.28.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@modern-js/module-tools": "^2.
|
|
45
|
+
"@modern-js/module-tools": "^2.28.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependenciesMeta": {
|
|
47
48
|
"@modern-js/module-tools": {
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAuC;AAEhC,IAAM,qBAAqB,CAAC,aAEJ;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO,OAAO;AAAA,IACZ,gBAAgB,QAAQ;AAT5B;AAUM,aAAO,mBAAkBA,cAAQ,iBAAR,aAAwB,CAAC;AAClD,aAAO;AAAA,IACT;AAAA,IACM,cAAc,QAAQ,MAAM;AAAA;AAbtC;AAeM,aAAIA,aAAO,YAAP,oBAAgB,KAAK,OAAK,EAAE,SAAS,mDAAyB;AAChE,iBAAO,KAAK,MAAM;AAAA,QACpB;AAEA,YAAI,CAAC,QAAQ,gBAAgB,QAAQ,aAAa,WAAW,GAAG;AAC9D,iBAAO,KAAK,MAAM;AAAA,QACpB;AAEA,cAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,+BAA+B;AACxE,qBAAO,YAAP,mBAAgB;AAAA,UACd,gBAAgB;AAAA,YACd,KAAK;AAAA;AAAA,cAEH,WAAW;AAAA,gBACT,OAAO;AAAA,kBACL,SAAS,OAAO,QAAQ,cAAc,YAAY;AAAA,gBACpD;AAAA,cACF;AAAA,YACF;AAAA,YACA,YAAY;AAAA,cACV,eAAc,aAAQ,iBAAR,YAAwB,CAAC;AAAA,YACzC;AAAA,UACF,CAAC;AAAA;AAGH,eAAO,KAAK,MAAM;AAAA,MACpB;AAAA;AAAA,EACF;AACF;AAGA,IAAO,cAAQ;","names":["_a"],"sources":["../src/index.ts"],"sourcesContent":["import type { CliPlugin, ModuleTools } from '@modern-js/module-tools';\nimport type { ImportItem } from '@modern-js/libuild-plugin-swc';\nimport { swcTransformPluginName } from '@modern-js/libuild-plugin-swc';\n\nexport const modulePluginImport = (options: {\n pluginImport?: ImportItem[];\n}): CliPlugin<ModuleTools> => ({\n name: '@modern-js/plugin-module-import',\n setup: () => ({\n beforeBuildTask(config) {\n config.transformImport = options.pluginImport ?? [];\n return config;\n },\n async modifyLibuild(config, next) {\n // when libuild:swc-transform found\n if (config.plugins?.find(p => p.name === swcTransformPluginName)) {\n return next(config);\n }\n\n if (!options.pluginImport || options.pluginImport.length === 0) {\n return next(config);\n }\n\n const { transformPlugin } = await import('@modern-js/libuild-plugin-swc');\n config.plugins?.push(\n transformPlugin({\n jsc: {\n // swc transform jsx to `React.createElement` in default mode.\n transform: {\n react: {\n runtime: config.jsx === 'transform' ? 'classic' : 'automatic',\n },\n },\n },\n extensions: {\n pluginImport: options.pluginImport ?? [],\n },\n }),\n );\n\n return next(config);\n },\n }),\n});\n\n// deprecated default export\nexport default modulePluginImport;\n"]}
|