@modern-js/plugin-module-import 2.7.0-beta.0 → 2.7.0-beta.2
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/dist/{index.js → cjs/index.js} +20 -46
- package/dist/esm/index.js +30 -0
- package/dist/types/index.d.ts +8 -0
- package/package.json +3 -3
- package/dist/index.d.ts +0 -8
- package/dist/index.js.map +0 -1
|
@@ -25,28 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
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
28
|
var src_exports = {};
|
|
51
29
|
__export(src_exports, {
|
|
52
30
|
default: () => src_default
|
|
@@ -55,33 +33,29 @@ module.exports = __toCommonJS(src_exports);
|
|
|
55
33
|
var src_default = (options) => ({
|
|
56
34
|
name: "@modern-js/plugin-module-import",
|
|
57
35
|
setup: () => ({
|
|
58
|
-
modifyLibuild(config, next) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
62
|
-
return next(config);
|
|
63
|
-
}
|
|
64
|
-
const { transformPlugin } = yield import("@modern-js/libuild-plugin-swc");
|
|
65
|
-
(_b = config.plugins) == null ? void 0 : _b.push(
|
|
66
|
-
transformPlugin({
|
|
67
|
-
jsc: {
|
|
68
|
-
parser: {
|
|
69
|
-
syntax: "ecmascript",
|
|
70
|
-
jsx: true
|
|
71
|
-
},
|
|
72
|
-
target: "es2022"
|
|
73
|
-
},
|
|
74
|
-
extensions: {
|
|
75
|
-
pluginImport: (_a2 = options.pluginImport) != null ? _a2 : []
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
);
|
|
36
|
+
async modifyLibuild(config, next) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
79
39
|
return next(config);
|
|
80
|
-
}
|
|
40
|
+
}
|
|
41
|
+
const { transformPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
42
|
+
(_b = config.plugins) == null ? void 0 : _b.push(
|
|
43
|
+
transformPlugin({
|
|
44
|
+
jsc: {
|
|
45
|
+
parser: {
|
|
46
|
+
syntax: "ecmascript",
|
|
47
|
+
jsx: true
|
|
48
|
+
},
|
|
49
|
+
target: "es2022"
|
|
50
|
+
},
|
|
51
|
+
extensions: {
|
|
52
|
+
pluginImport: (_a = options.pluginImport) != null ? _a : []
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
return next(config);
|
|
81
57
|
}
|
|
82
58
|
})
|
|
83
59
|
});
|
|
84
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
61
|
0 && (module.exports = {});
|
|
86
|
-
|
|
87
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var src_default = (options) => ({
|
|
2
|
+
name: "@modern-js/plugin-module-import",
|
|
3
|
+
setup: () => ({
|
|
4
|
+
async modifyLibuild(config, next) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (!options.pluginImport || options.pluginImport.length === 0) {
|
|
7
|
+
return next(config);
|
|
8
|
+
}
|
|
9
|
+
const { transformPlugin } = await import("@modern-js/libuild-plugin-swc");
|
|
10
|
+
(_b = config.plugins) == null ? void 0 : _b.push(
|
|
11
|
+
transformPlugin({
|
|
12
|
+
jsc: {
|
|
13
|
+
parser: {
|
|
14
|
+
syntax: "ecmascript",
|
|
15
|
+
jsx: true
|
|
16
|
+
},
|
|
17
|
+
target: "es2022"
|
|
18
|
+
},
|
|
19
|
+
extensions: {
|
|
20
|
+
pluginImport: (_a = options.pluginImport) != null ? _a : []
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
return next(config);
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
src_default as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CliPlugin, ModuleTools } from '@modern-js/module-tools';
|
|
2
|
+
import type { ImportItem } from '@modern-js/libuild-plugin-swc';
|
|
3
|
+
|
|
4
|
+
declare const _default: (options: {
|
|
5
|
+
pluginImport?: ImportItem[];
|
|
6
|
+
}) => CliPlugin<ModuleTools>;
|
|
7
|
+
|
|
8
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.7.0-beta.
|
|
14
|
+
"version": "2.7.0-beta.2",
|
|
15
15
|
"types": "./dist/types/index.d.ts",
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
17
|
"dependencies": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"jest": "^27",
|
|
25
25
|
"@modern-js/libuild": "~0.11.0",
|
|
26
26
|
"@scripts/build": "2.7.0",
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
27
|
+
"@scripts/jest-config": "2.7.0",
|
|
28
|
+
"@modern-js/module-tools": "2.7.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@modern-js/module-tools": "2.7.0"
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CliPlugin, ModuleTools } from '@modern-js/module-tools';
|
|
2
|
-
import { ImportItem } from '@modern-js/libuild-plugin-swc';
|
|
3
|
-
|
|
4
|
-
declare const _default: (options: {
|
|
5
|
-
pluginImport?: ImportItem[];
|
|
6
|
-
}) => CliPlugin<ModuleTools>;
|
|
7
|
-
|
|
8
|
-
export { _default as default };
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAO,cAAQ,CAAC,aAEe;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO,OAAO;AAAA,IACN,cAAc,QAAQ,MAAM;AAAA;AARtC;AASM,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,cACH,QAAQ;AAAA,gBACN,QAAQ;AAAA,gBACR,KAAK;AAAA,cACP;AAAA,cACA,QAAQ;AAAA,YACV;AAAA,YACA,YAAY;AAAA,cACV,eAAcA,cAAQ,iBAAR,aAAwB,CAAC;AAAA,YACzC;AAAA,UACF,CAAC;AAAA;AAGH,eAAO,KAAK,MAAM;AAAA,MACpB;AAAA;AAAA,EACF;AACF;","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';\n\nexport default (options: {\n pluginImport?: ImportItem[];\n}): CliPlugin<ModuleTools> => ({\n name: '@modern-js/plugin-module-import',\n setup: () => ({\n async modifyLibuild(config, next) {\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 parser: {\n syntax: 'ecmascript',\n jsx: true,\n },\n target: 'es2022',\n },\n extensions: {\n pluginImport: options.pluginImport ?? [],\n },\n }),\n );\n\n return next(config);\n },\n }),\n});\n"]}
|