@modern-js/plugin-module-import 2.21.1 → 2.22.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 +17 -0
- package/README.md +3 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -0
- package/package.json +11 -13
- package/dist/cjs/index.js +0 -49
- package/dist/esm/index.js +0 -40
- package/dist/types/index.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @modern-js/plugin-module-import
|
|
2
2
|
|
|
3
|
+
## 2.22.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ad49140: chore: adjust output and package.json fields
|
|
8
|
+
chore: 调整包的产物格式以及 packgae.json 里的字段
|
|
9
|
+
- 4b7488c: chore(deps): bump libuild v0.12.4 and swc-plugins v0.3.5
|
|
10
|
+
|
|
11
|
+
chore(deps): 升级 libuild v0.12.4 和 swc-plugins v0.3.5
|
|
12
|
+
|
|
13
|
+
- e2913dd: chore: update module plugin docs and readme
|
|
14
|
+
chore: 更新模块插件的文档和 readme
|
|
15
|
+
- Updated dependencies [d19dc11]
|
|
16
|
+
- Updated dependencies [c890980]
|
|
17
|
+
- Updated dependencies [4b7488c]
|
|
18
|
+
- @modern-js/module-tools@2.22.0
|
|
19
|
+
|
|
3
20
|
## 2.21.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,12 +8,12 @@ A Library author don't want to "pollute" the global scope with the polyfills you
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
-
```ts
|
|
11
|
+
```ts modern.config.ts
|
|
12
12
|
import { defineConfig } from '@modern-js/module-tools';
|
|
13
|
-
import
|
|
13
|
+
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
14
14
|
|
|
15
15
|
export default defineConfig({
|
|
16
|
-
plugins: [
|
|
16
|
+
plugins: [modulePluginImport({
|
|
17
17
|
pluginImport: [
|
|
18
18
|
{
|
|
19
19
|
libraryName: 'antd',
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CliPlugin, ModuleTools } from '@modern-js/module-tools';
|
|
2
|
+
import { ImportItem } from '@modern-js/libuild-plugin-swc';
|
|
3
|
+
|
|
4
|
+
declare const modulePluginImport: (options: {
|
|
5
|
+
pluginImport?: ImportItem[];
|
|
6
|
+
}) => CliPlugin<ModuleTools>;
|
|
7
|
+
|
|
8
|
+
export { modulePluginImport as default, modulePluginImport };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
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 __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
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(src_exports);
|
|
56
|
+
var import_libuild_plugin_swc = require("@modern-js/libuild-plugin-swc");
|
|
57
|
+
var modulePluginImport = (options) => ({
|
|
58
|
+
name: "@modern-js/plugin-module-import",
|
|
59
|
+
setup: () => ({
|
|
60
|
+
beforeBuildTask(config) {
|
|
61
|
+
var _a2;
|
|
62
|
+
config.transformImport = (_a2 = options.pluginImport) != null ? _a2 : [];
|
|
63
|
+
return config;
|
|
64
|
+
},
|
|
65
|
+
modifyLibuild(config, next) {
|
|
66
|
+
return __async(this, null, function* () {
|
|
67
|
+
var _a2, _b, _c;
|
|
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
|
+
);
|
|
90
|
+
return next(config);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
var src_default = modulePluginImport;
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
modulePluginImport
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
package/package.json
CHANGED
|
@@ -15,21 +15,19 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"main": "./dist/
|
|
18
|
+
"version": "2.22.0",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"node": {
|
|
24
24
|
"jsnext:source": "./src/index.ts",
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"default": "./dist/esm/index.js"
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
|
+
}
|
|
29
27
|
}
|
|
30
28
|
},
|
|
31
29
|
"dependencies": {
|
|
32
|
-
"@modern-js/libuild-plugin-swc": "0.12.
|
|
30
|
+
"@modern-js/libuild-plugin-swc": "0.12.4",
|
|
33
31
|
"@swc/helpers": "0.5.1"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
@@ -37,13 +35,13 @@
|
|
|
37
35
|
"@types/node": "^14",
|
|
38
36
|
"typescript": "^5",
|
|
39
37
|
"jest": "^29",
|
|
40
|
-
"@modern-js/libuild": "0.12.
|
|
41
|
-
"@scripts/build": "2.
|
|
42
|
-
"@scripts/jest-config": "2.
|
|
43
|
-
"@modern-js/module-tools": "2.
|
|
38
|
+
"@modern-js/libuild": "0.12.4",
|
|
39
|
+
"@scripts/build": "2.22.0",
|
|
40
|
+
"@scripts/jest-config": "2.22.0",
|
|
41
|
+
"@modern-js/module-tools": "2.22.0"
|
|
44
42
|
},
|
|
45
43
|
"peerDependencies": {
|
|
46
|
-
"@modern-js/module-tools": "^2.
|
|
44
|
+
"@modern-js/module-tools": "^2.22.0"
|
|
47
45
|
},
|
|
48
46
|
"peerDependenciesMeta": {
|
|
49
47
|
"@modern-js/module-tools": {
|
package/dist/cjs/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => _default
|
|
8
|
-
});
|
|
9
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
|
-
const _libuildpluginswc = require("@modern-js/libuild-plugin-swc");
|
|
11
|
-
const _default = (options) => {
|
|
12
|
-
return {
|
|
13
|
-
name: "@modern-js/plugin-module-import",
|
|
14
|
-
setup: () => {
|
|
15
|
-
return {
|
|
16
|
-
beforeBuildTask(config) {
|
|
17
|
-
var _options_pluginImport;
|
|
18
|
-
config.transformImport = (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : [];
|
|
19
|
-
return config;
|
|
20
|
-
},
|
|
21
|
-
async modifyLibuild(config, next) {
|
|
22
|
-
var _config_plugins, _config_plugins1;
|
|
23
|
-
if ((_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.find((p) => p.name === _libuildpluginswc.swcTransformPluginName)) {
|
|
24
|
-
return next(config);
|
|
25
|
-
}
|
|
26
|
-
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
27
|
-
return next(config);
|
|
28
|
-
}
|
|
29
|
-
const { transformPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/libuild-plugin-swc")));
|
|
30
|
-
var _options_pluginImport;
|
|
31
|
-
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(transformPlugin({
|
|
32
|
-
jsc: {
|
|
33
|
-
// swc transform jsx to `React.createElement` in default mode.
|
|
34
|
-
transform: {
|
|
35
|
-
react: {
|
|
36
|
-
runtime: config.jsx === "transform" ? "classic" : "automatic"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
extensions: {
|
|
41
|
-
pluginImport: (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : []
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
return next(config);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
};
|
package/dist/esm/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
extensions: {
|
|
32
|
-
pluginImport: (_options_pluginImport = options.pluginImport) !== null && _options_pluginImport !== void 0 ? _options_pluginImport : []
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
return next(config);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
package/dist/types/index.d.ts
DELETED