@modern-js/runtime 3.1.3 → 3.1.4

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.
@@ -48,8 +48,8 @@ var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namesp
48
48
  const external_path_namespaceObject = require("path");
49
49
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
50
50
  const utils_namespaceObject = require("@modern-js/utils");
51
+ const core_namespaceObject = require("@swc/core");
51
52
  const external_es_module_lexer_namespaceObject = require("es-module-lexer");
52
- const external_esbuild_namespaceObject = require("esbuild");
53
53
  const external_constants_js_namespaceObject = require("../constants.js");
54
54
  const walkDirectory = (dir)=>external_fs_default().readdirSync(dir).reduce((previous, filename)=>{
55
55
  const filePath = external_path_default().join(dir, filename);
@@ -79,13 +79,30 @@ const replaceWithAlias = (base, filePath, alias)=>{
79
79
  const parseModule = async ({ source, filename })=>{
80
80
  let content = source;
81
81
  if (utils_namespaceObject.JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
82
- const result = await (0, external_esbuild_namespaceObject.transform)(content, {
83
- loader: external_path_default().extname(filename).slice(1),
84
- format: 'esm',
85
- tsconfigRaw: {
86
- compilerOptions: {
87
- experimentalDecorators: true
88
- }
82
+ const ext = external_path_default().extname(filename);
83
+ const isTs = '.ts' === ext || '.tsx' === ext;
84
+ const isJsx = '.jsx' === ext || '.tsx' === ext;
85
+ const result = await (0, core_namespaceObject.transform)(content, {
86
+ filename,
87
+ isModule: true,
88
+ module: {
89
+ type: 'es6'
90
+ },
91
+ jsc: {
92
+ parser: isTs ? {
93
+ syntax: "typescript",
94
+ tsx: isJsx,
95
+ decorators: true
96
+ } : {
97
+ syntax: "ecmascript",
98
+ jsx: isJsx,
99
+ decorators: true
100
+ },
101
+ transform: {
102
+ legacyDecorator: true
103
+ },
104
+ target: 'es2022',
105
+ keepClassNames: true
89
106
  }
90
107
  });
91
108
  content = result.code;
@@ -1,8 +1,8 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { JS_EXTENSIONS, fs as utils_fs, normalizeToPosixPath } from "@modern-js/utils";
4
+ import { transform } from "@swc/core";
4
5
  import { parse } from "es-module-lexer";
5
- import { transform } from "esbuild";
6
6
  import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants.mjs";
7
7
  const walkDirectory = (dir)=>fs.readdirSync(dir).reduce((previous, filename)=>{
8
8
  const filePath = path.join(dir, filename);
@@ -32,13 +32,30 @@ const replaceWithAlias = (base, filePath, alias)=>{
32
32
  const parseModule = async ({ source, filename })=>{
33
33
  let content = source;
34
34
  if (JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
35
+ const ext = path.extname(filename);
36
+ const isTs = '.ts' === ext || '.tsx' === ext;
37
+ const isJsx = '.jsx' === ext || '.tsx' === ext;
35
38
  const result = await transform(content, {
36
- loader: path.extname(filename).slice(1),
37
- format: 'esm',
38
- tsconfigRaw: {
39
- compilerOptions: {
40
- experimentalDecorators: true
41
- }
39
+ filename,
40
+ isModule: true,
41
+ module: {
42
+ type: 'es6'
43
+ },
44
+ jsc: {
45
+ parser: isTs ? {
46
+ syntax: "typescript",
47
+ tsx: isJsx,
48
+ decorators: true
49
+ } : {
50
+ syntax: "ecmascript",
51
+ jsx: isJsx,
52
+ decorators: true
53
+ },
54
+ transform: {
55
+ legacyDecorator: true
56
+ },
57
+ target: 'es2022',
58
+ keepClassNames: true
42
59
  }
43
60
  });
44
61
  content = result.code;
@@ -2,8 +2,8 @@ import "node:module";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
  import { JS_EXTENSIONS, fs as utils_fs, normalizeToPosixPath } from "@modern-js/utils";
5
+ import { transform } from "@swc/core";
5
6
  import { parse } from "es-module-lexer";
6
- import { transform } from "esbuild";
7
7
  import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants.mjs";
8
8
  const walkDirectory = (dir)=>fs.readdirSync(dir).reduce((previous, filename)=>{
9
9
  const filePath = path.join(dir, filename);
@@ -33,13 +33,30 @@ const replaceWithAlias = (base, filePath, alias)=>{
33
33
  const parseModule = async ({ source, filename })=>{
34
34
  let content = source;
35
35
  if (JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
36
+ const ext = path.extname(filename);
37
+ const isTs = '.ts' === ext || '.tsx' === ext;
38
+ const isJsx = '.jsx' === ext || '.tsx' === ext;
36
39
  const result = await transform(content, {
37
- loader: path.extname(filename).slice(1),
38
- format: 'esm',
39
- tsconfigRaw: {
40
- compilerOptions: {
41
- experimentalDecorators: true
42
- }
40
+ filename,
41
+ isModule: true,
42
+ module: {
43
+ type: 'es6'
44
+ },
45
+ jsc: {
46
+ parser: isTs ? {
47
+ syntax: "typescript",
48
+ tsx: isJsx,
49
+ decorators: true
50
+ } : {
51
+ syntax: "ecmascript",
52
+ jsx: isJsx,
53
+ decorators: true
54
+ },
55
+ transform: {
56
+ legacyDecorator: true
57
+ },
58
+ target: 'es2022',
59
+ keepClassNames: true
43
60
  }
44
61
  });
45
62
  content = result.code;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.1.3",
18
+ "version": "3.1.4",
19
19
  "engines": {
20
20
  "node": ">=20"
21
21
  },
@@ -204,23 +204,23 @@
204
204
  "@loadable/component": "5.16.7",
205
205
  "@loadable/server": "5.16.7",
206
206
  "@swc/helpers": "^0.5.17",
207
+ "@swc/core": "1.15.11",
207
208
  "@swc/plugin-loadable-components": "^11.5.0",
208
209
  "@types/loadable__component": "^5.13.10",
209
210
  "@types/react-helmet": "^6.1.11",
210
211
  "cookie": "0.7.2",
211
212
  "entities": "^7.0.1",
212
213
  "es-module-lexer": "^1.7.0",
213
- "esbuild": "0.25.5",
214
214
  "invariant": "^2.2.4",
215
215
  "isbot": "3.8.0",
216
216
  "react-helmet": "^6.1.0",
217
217
  "react-is": "^18.3.1",
218
- "@modern-js/plugin": "3.1.3",
219
- "@modern-js/runtime-utils": "3.1.3",
220
- "@modern-js/render": "3.1.3",
221
- "@modern-js/plugin-data-loader": "3.1.3",
222
- "@modern-js/utils": "3.1.3",
223
- "@modern-js/types": "3.1.3"
218
+ "@modern-js/plugin": "3.1.4",
219
+ "@modern-js/plugin-data-loader": "3.1.4",
220
+ "@modern-js/runtime-utils": "3.1.4",
221
+ "@modern-js/types": "3.1.4",
222
+ "@modern-js/render": "3.1.4",
223
+ "@modern-js/utils": "3.1.4"
224
224
  },
225
225
  "peerDependencies": {
226
226
  "react": ">=17.0.2",
@@ -240,9 +240,9 @@
240
240
  "react-dom": "^19.2.4",
241
241
  "ts-node": "^10.9.2",
242
242
  "typescript": "^5",
243
- "@modern-js/app-tools": "3.1.3",
243
+ "@scripts/rstest-config": "2.66.0",
244
244
  "@modern-js/rslib": "2.68.10",
245
- "@scripts/rstest-config": "2.66.0"
245
+ "@modern-js/app-tools": "3.1.4"
246
246
  },
247
247
  "sideEffects": false,
248
248
  "publishConfig": {