@bleedingdev/modern-js-plugin 3.11.3-ultramodern.15 → 3.11.3-ultramodern.16
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.
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return "u" < typeof document ? require('url'.replace('', '')).pathToFileURL(__filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
2
5
|
var __webpack_require__ = {};
|
|
3
6
|
(()=>{
|
|
4
7
|
__webpack_require__.n = (module)=>{
|
|
@@ -41,6 +44,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
41
44
|
loadConfig: ()=>loadConfig,
|
|
42
45
|
loadTypeScriptFile: ()=>loadTypeScriptFile
|
|
43
46
|
});
|
|
47
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
48
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
44
49
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
45
50
|
const external_jiti_namespaceObject = require("jiti");
|
|
46
51
|
const external_path_namespaceObject = require("path");
|
|
@@ -51,15 +56,32 @@ const getConfigFilePath = (appDirectory, configFilePath)=>{
|
|
|
51
56
|
return external_path_default().resolve(appDirectory, configFilePath);
|
|
52
57
|
};
|
|
53
58
|
async function loadConfigContent(configFile) {
|
|
54
|
-
const
|
|
59
|
+
const isESM = false;
|
|
60
|
+
const jitiFrom = isESM ? __rslib_import_meta_url__ : __filename;
|
|
61
|
+
const transformer = (0, external_jiti_namespaceObject.createJiti)(jitiFrom, {
|
|
62
|
+
fsCache: false
|
|
63
|
+
});
|
|
55
64
|
const jiti = (0, external_jiti_namespaceObject.createJiti)(jitiFrom, {
|
|
56
65
|
requireCache: false,
|
|
57
|
-
interopDefault: true
|
|
66
|
+
interopDefault: true,
|
|
67
|
+
...!isESM && {
|
|
68
|
+
fsCache: false,
|
|
69
|
+
transform: (options)=>{
|
|
70
|
+
const filename = options.filename;
|
|
71
|
+
const installedDependency = filename?.split(/[\\/]/).includes('node_modules');
|
|
72
|
+
const packageFile = installedDependency && filename?.endsWith('.js') ? (0, external_node_module_namespaceObject.findPackageJSON)((0, external_node_url_namespaceObject.pathToFileURL)(filename)) : void 0;
|
|
73
|
+
if (installedDependency && (filename?.endsWith('.mjs') || packageFile && JSON.parse(utils_namespaceObject.fs.readFileSync(packageFile, 'utf8'))?.type === 'module')) return {
|
|
74
|
+
code: 'module.exports = require("node:module").createRequire(__filename)(__filename);'
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
code: transformer.transform(options)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
58
81
|
});
|
|
59
82
|
if (!utils_namespaceObject.fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
60
83
|
try {
|
|
61
|
-
|
|
62
|
-
config = jiti(configFile);
|
|
84
|
+
const config = isESM ? await jiti.import(configFile, {}) : jiti(configFile);
|
|
63
85
|
return config.default || config;
|
|
64
86
|
} catch (e) {
|
|
65
87
|
if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { findPackageJSON } from "node:module";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
1
3
|
import { compatibleRequire, fs } from "@modern-js/utils";
|
|
2
4
|
import { createJiti } from "jiti";
|
|
3
5
|
import path from "path";
|
|
@@ -7,15 +9,32 @@ const getConfigFilePath = (appDirectory, configFilePath)=>{
|
|
|
7
9
|
return path.resolve(appDirectory, configFilePath);
|
|
8
10
|
};
|
|
9
11
|
async function loadConfigContent(configFile) {
|
|
10
|
-
const
|
|
12
|
+
const isESM = true;
|
|
13
|
+
const jitiFrom = isESM ? import.meta.url : __filename;
|
|
14
|
+
const transformer = createJiti(jitiFrom, {
|
|
15
|
+
fsCache: false
|
|
16
|
+
});
|
|
11
17
|
const jiti = createJiti(jitiFrom, {
|
|
12
18
|
requireCache: false,
|
|
13
|
-
interopDefault: true
|
|
19
|
+
interopDefault: true,
|
|
20
|
+
...!isESM && {
|
|
21
|
+
fsCache: false,
|
|
22
|
+
transform: (options)=>{
|
|
23
|
+
const filename = options.filename;
|
|
24
|
+
const installedDependency = filename?.split(/[\\/]/).includes('node_modules');
|
|
25
|
+
const packageFile = installedDependency && filename?.endsWith('.js') ? findPackageJSON(pathToFileURL(filename)) : void 0;
|
|
26
|
+
if (installedDependency && (filename?.endsWith('.mjs') || packageFile && JSON.parse(fs.readFileSync(packageFile, 'utf8'))?.type === 'module')) return {
|
|
27
|
+
code: 'module.exports = require("node:module").createRequire(__filename)(__filename);'
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
code: transformer.transform(options)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
14
34
|
});
|
|
15
35
|
if (!fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
16
36
|
try {
|
|
17
|
-
|
|
18
|
-
config = await jiti.import(configFile, {});
|
|
37
|
+
const config = isESM ? await jiti.import(configFile, {}) : jiti(configFile);
|
|
19
38
|
return config.default || config;
|
|
20
39
|
} catch (e) {
|
|
21
40
|
if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { findPackageJSON } from "node:module";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
2
4
|
import { compatibleRequire, fs } from "@modern-js/utils";
|
|
3
5
|
import { createJiti } from "jiti";
|
|
4
6
|
import path from "path";
|
|
@@ -10,15 +12,32 @@ const getConfigFilePath = (appDirectory, configFilePath)=>{
|
|
|
10
12
|
return path.resolve(appDirectory, configFilePath);
|
|
11
13
|
};
|
|
12
14
|
async function loadConfigContent(configFile) {
|
|
13
|
-
const
|
|
15
|
+
const isESM = true;
|
|
16
|
+
const jitiFrom = isESM ? import.meta.url : __rspack_import_meta_filename__;
|
|
17
|
+
const transformer = createJiti(jitiFrom, {
|
|
18
|
+
fsCache: false
|
|
19
|
+
});
|
|
14
20
|
const jiti = createJiti(jitiFrom, {
|
|
15
21
|
requireCache: false,
|
|
16
|
-
interopDefault: true
|
|
22
|
+
interopDefault: true,
|
|
23
|
+
...!isESM && {
|
|
24
|
+
fsCache: false,
|
|
25
|
+
transform: (options)=>{
|
|
26
|
+
const filename = options.filename;
|
|
27
|
+
const installedDependency = filename?.split(/[\\/]/).includes('node_modules');
|
|
28
|
+
const packageFile = installedDependency && filename?.endsWith('.js') ? findPackageJSON(pathToFileURL(filename)) : void 0;
|
|
29
|
+
if (installedDependency && (filename?.endsWith('.mjs') || packageFile && JSON.parse(fs.readFileSync(packageFile, 'utf8'))?.type === 'module')) return {
|
|
30
|
+
code: 'module.exports = require("node:module").createRequire(__filename)(__filename);'
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
code: transformer.transform(options)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
17
37
|
});
|
|
18
38
|
if (!fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
19
39
|
try {
|
|
20
|
-
|
|
21
|
-
config = await jiti.import(configFile, {});
|
|
40
|
+
const config = isESM ? await jiti.import(configFile, {}) : jiti(configFile);
|
|
22
41
|
return config.default || config;
|
|
23
42
|
} catch (e) {
|
|
24
43
|
if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.11.3-ultramodern.
|
|
20
|
+
"version": "3.11.3-ultramodern.16",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -79,15 +79,15 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.11.3-ultramodern.
|
|
83
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.11.3-ultramodern.
|
|
84
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.11.3-ultramodern.
|
|
82
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.11.3-ultramodern.16",
|
|
83
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.11.3-ultramodern.16",
|
|
84
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.11.3-ultramodern.16",
|
|
85
85
|
"@rsbuild/core": "2.3.3",
|
|
86
86
|
"@swc/helpers": "^0.5.24",
|
|
87
87
|
"jiti": "2.7.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.11.3-ultramodern.
|
|
90
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.11.3-ultramodern.16",
|
|
91
91
|
"@rslib/core": "1.0.7",
|
|
92
92
|
"@types/node": "^26.6.6",
|
|
93
93
|
"@types/react": "^19.3.0",
|