@modern-js/plugin-module-polyfill 2.35.1 → 2.37.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  import type { CliPlugin, ModuleTools } from '@modern-js/module-tools';
2
- export declare const ModulePolyfillPlugin: (options?: {
2
+ export type Options = {
3
3
  targets?: Record<string, string> | string;
4
- }) => CliPlugin<ModuleTools>;
5
- export { ModulePolyfillPlugin as modulePluginPolyfill };
4
+ };
5
+ export declare const getPolyfillHook: (options?: Options) => {
6
+ name: string;
7
+ apply(compiler: import("@modern-js/module-tools").ICompiler): void;
8
+ };
9
+ export declare const modulePluginPolyfill: (options?: Options) => CliPlugin<ModuleTools>;
10
+ /**
11
+ * deprecated named export
12
+ * @deprecated
13
+ */
14
+ export declare const ModulePolyfillPlugin: (options?: Options) => CliPlugin<ModuleTools>;
package/dist/index.js CHANGED
@@ -1,50 +1,65 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
7
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- ModulePolyfillPlugin: function() {
14
- return ModulePolyfillPlugin;
15
- },
16
- modulePluginPolyfill: function() {
17
- return ModulePolyfillPlugin;
8
+ __defProp(target, name, { get: all[name], 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 });
18
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ ModulePolyfillPlugin: () => ModulePolyfillPlugin,
22
+ getPolyfillHook: () => getPolyfillHook,
23
+ modulePluginPolyfill: () => modulePluginPolyfill
19
24
  });
20
- const _libuildpluginbabel = require("@modern-js/libuild-plugin-babel");
21
- const ModulePolyfillPlugin = (options) => ({
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_plugin_module_babel = require("@modern-js/plugin-module-babel");
27
+ const getPolyfillHook = (options) => {
28
+ const plugins = [
29
+ [
30
+ require("@babel/plugin-syntax-typescript"),
31
+ {
32
+ isTSX: true
33
+ }
34
+ ],
35
+ [
36
+ require("@babel/plugin-syntax-jsx")
37
+ ],
38
+ [
39
+ require("babel-plugin-polyfill-corejs3"),
40
+ {
41
+ method: "usage-pure",
42
+ targets: options === null || options === void 0 ? void 0 : options.targets
43
+ }
44
+ ]
45
+ ];
46
+ return (0, import_plugin_module_babel.getBabelHook)({
47
+ plugins
48
+ });
49
+ };
50
+ const modulePluginPolyfill = (options) => ({
22
51
  name: "@modern-js/plugin-module-polyfill",
23
52
  setup: () => ({
24
- modifyLibuild(config) {
25
- var _config_plugins;
26
- const plugins = [
27
- [
28
- require("@babel/plugin-syntax-typescript"),
29
- {
30
- isTSX: true
31
- }
32
- ],
33
- [
34
- require("@babel/plugin-syntax-jsx")
35
- ],
36
- [
37
- require("babel-plugin-polyfill-corejs3"),
38
- {
39
- method: "usage-pure",
40
- targets: options === null || options === void 0 ? void 0 : options.targets
41
- }
42
- ]
43
- ];
44
- (_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push((0, _libuildpluginbabel.babelPlugin)({
45
- plugins
46
- }));
53
+ beforeBuildTask(config) {
54
+ config.hooks.push(getPolyfillHook(options));
47
55
  return config;
48
56
  }
49
57
  })
50
58
  });
59
+ const ModulePolyfillPlugin = modulePluginPolyfill;
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ ModulePolyfillPlugin,
63
+ getPolyfillHook,
64
+ modulePluginPolyfill
65
+ });
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "@modern-js/plugin-module-polyfill",
3
- "description": "The polyfill plugin of Modern.js Module.",
3
+ "version": "2.37.0",
4
+ "description": "The polyfill 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,45 +16,38 @@
9
16
  "directory": "packages/module/plugin-module-polyfill"
10
17
  },
11
18
  "license": "MIT",
12
- "keywords": [
13
- "react",
14
- "framework",
15
- "modern",
16
- "modern.js"
17
- ],
18
- "version": "2.35.1",
19
- "types": "./dist/index.d.ts",
19
+ "sideEffects": false,
20
20
  "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "dependencies": {
23
+ "@babel/core": "^7.22.5",
24
+ "@babel/plugin-syntax-jsx": "7.22.5",
25
+ "@babel/plugin-syntax-typescript": "7.22.5",
26
+ "babel-plugin-polyfill-corejs3": "0.5.2",
27
+ "@modern-js/plugin-module-babel": "2.37.0"
28
+ },
21
29
  "devDependencies": {
30
+ "@swc/helpers": "0.5.1",
22
31
  "@types/jest": "^29",
23
32
  "@types/node": "^14",
24
- "typescript": "^5",
25
33
  "jest": "^29",
26
- "@swc/helpers": "0.5.1",
27
- "@modern-js/module-tools": "2.35.1",
28
- "@scripts/jest-config": "2.35.1",
29
- "@scripts/build": "2.35.1"
34
+ "typescript": "^5",
35
+ "@scripts/build": "2.37.0",
36
+ "@scripts/jest-config": "2.37.0",
37
+ "@modern-js/module-tools": "2.37.0"
30
38
  },
31
39
  "peerDependencies": {
32
- "@modern-js/module-tools": "^2.35.1",
40
+ "@modern-js/module-tools": "^2.37.0",
33
41
  "core-js-pure": "^3.25.0"
34
42
  },
35
- "dependencies": {
36
- "@babel/core": "^7.22.15",
37
- "@babel/plugin-syntax-typescript": "^7.22.5",
38
- "@babel/plugin-syntax-jsx": "^7.22.5",
39
- "babel-plugin-polyfill-corejs3": "0.5.2",
40
- "@modern-js/libuild-plugin-babel": "2.35.1"
41
- },
42
- "sideEffects": false,
43
43
  "publishConfig": {
44
- "registry": "https://registry.npmjs.org/",
45
44
  "access": "public",
46
- "provenance": true
45
+ "provenance": true,
46
+ "registry": "https://registry.npmjs.org/"
47
47
  },
48
48
  "scripts": {
49
- "dev": "mdn build --watch",
50
49
  "build": "mdn build",
50
+ "dev": "mdn build --watch",
51
51
  "test": "jest --passWithNoTests"
52
52
  }
53
53
  }