@modern-js/plugin-module-babel 2.35.0 → 2.36.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/dist/index.d.ts +12 -5
- package/dist/index.js +63 -19
- package/package.json +21 -20
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { TransformOptions as BabelTransformOptions } from '@babel/core';
|
|
2
|
+
import { CliPlugin, ICompiler, ModuleTools } from '@modern-js/module-tools';
|
|
3
|
+
export declare const getBabelHook: (options?: BabelTransformOptions) => {
|
|
4
|
+
name: string;
|
|
5
|
+
apply(compiler: ICompiler): void;
|
|
6
|
+
};
|
|
7
|
+
export declare const modulePluginBabel: (options?: BabelTransformOptions) => CliPlugin<ModuleTools>;
|
|
8
|
+
/**
|
|
9
|
+
* deprecated named export, use modulePluginBabel instead.
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export declare const ModulePluginBabel: (options?: BabelTransformOptions) => CliPlugin<ModuleTools>;
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
ModulePluginBabel: () => ModulePluginBabel,
|
|
22
|
+
getBabelHook: () => getBabelHook,
|
|
23
|
+
modulePluginBabel: () => modulePluginBabel
|
|
4
24
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_module_tools = require("@modern-js/module-tools");
|
|
27
|
+
const name = "babel";
|
|
28
|
+
const getBabelHook = (options) => ({
|
|
29
|
+
name,
|
|
30
|
+
apply(compiler) {
|
|
31
|
+
compiler.hooks.transform.tapPromise({
|
|
32
|
+
name
|
|
33
|
+
}, async (args) => {
|
|
34
|
+
if ((0, import_module_tools.isJsExt)(args.path) || (0, import_module_tools.isJsLoader)(args.loader)) {
|
|
35
|
+
const result = await require("@babel/core").transformAsync(args.code, {
|
|
36
|
+
filename: args.path,
|
|
37
|
+
sourceMaps: Boolean(compiler.config.sourceMap),
|
|
38
|
+
sourceType: "unambiguous",
|
|
39
|
+
inputSourceMap: false,
|
|
40
|
+
babelrc: false,
|
|
41
|
+
configFile: false,
|
|
42
|
+
compact: false,
|
|
43
|
+
exclude: [
|
|
44
|
+
/\bcore-js\b/
|
|
45
|
+
],
|
|
46
|
+
...options
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
...args,
|
|
50
|
+
code: result === null || result === void 0 ? void 0 : result.code,
|
|
51
|
+
map: result === null || result === void 0 ? void 0 : result.map
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return args;
|
|
10
55
|
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
ModulePluginBabel: function() {
|
|
14
|
-
return ModulePluginBabel;
|
|
15
|
-
},
|
|
16
|
-
modulePluginBabel: function() {
|
|
17
|
-
return ModulePluginBabel;
|
|
18
56
|
}
|
|
19
57
|
});
|
|
20
|
-
const
|
|
21
|
-
const ModulePluginBabel = (options) => ({
|
|
58
|
+
const modulePluginBabel = (options) => ({
|
|
22
59
|
name: "babel-plugin",
|
|
23
60
|
setup: () => ({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
61
|
+
beforeBuildTask(config) {
|
|
62
|
+
const hook = getBabelHook(options);
|
|
63
|
+
config.hooks.push(hook);
|
|
27
64
|
return config;
|
|
28
65
|
}
|
|
29
66
|
})
|
|
30
67
|
});
|
|
68
|
+
const ModulePluginBabel = modulePluginBabel;
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
ModulePluginBabel,
|
|
72
|
+
getBabelHook,
|
|
73
|
+
modulePluginBabel
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/plugin-module-babel",
|
|
3
|
-
"
|
|
3
|
+
"version": "2.36.0",
|
|
4
|
+
"description": "The babel plugin of Modern.js Module",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"framework",
|
|
8
|
+
"modern",
|
|
9
|
+
"modern.js"
|
|
10
|
+
],
|
|
4
11
|
"homepage": "https://modernjs.dev/module-tools",
|
|
5
12
|
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
13
|
"repository": {
|
|
@@ -9,40 +16,34 @@
|
|
|
9
16
|
"directory": "packages/module/plugin-module-babel"
|
|
10
17
|
},
|
|
11
18
|
"license": "MIT",
|
|
12
|
-
"
|
|
13
|
-
"react",
|
|
14
|
-
"framework",
|
|
15
|
-
"modern",
|
|
16
|
-
"modern.js"
|
|
17
|
-
],
|
|
18
|
-
"version": "2.35.0",
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
19
|
+
"sideEffects": false,
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
23
|
+
"@babel/core": "^7.22.5",
|
|
24
|
+
"@swc/helpers": "0.5.1"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
27
|
+
"@types/babel__core": "7.1.16",
|
|
26
28
|
"@types/jest": "^29",
|
|
27
29
|
"@types/node": "^14",
|
|
28
|
-
"typescript": "^5",
|
|
29
30
|
"jest": "^29",
|
|
30
|
-
"
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
31
|
+
"typescript": "^5",
|
|
32
|
+
"@modern-js/module-tools": "2.36.0",
|
|
33
|
+
"@scripts/build": "2.36.0",
|
|
34
|
+
"@scripts/jest-config": "2.36.0"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
|
-
"@modern-js/module-tools": "^2.
|
|
37
|
+
"@modern-js/module-tools": "^2.36.0"
|
|
36
38
|
},
|
|
37
|
-
"sideEffects": false,
|
|
38
39
|
"publishConfig": {
|
|
39
|
-
"registry": "https://registry.npmjs.org/",
|
|
40
40
|
"access": "public",
|
|
41
|
-
"provenance": true
|
|
41
|
+
"provenance": true,
|
|
42
|
+
"registry": "https://registry.npmjs.org/"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
|
-
"dev": "mdn build --watch",
|
|
45
45
|
"build": "mdn build",
|
|
46
|
+
"dev": "mdn build --watch",
|
|
46
47
|
"test": "jest --passWithNoTests"
|
|
47
48
|
}
|
|
48
49
|
}
|