@modern-js/plugin-v2 0.0.0-nightly-20250122164656 → 0.0.0-nightly-20250123160326
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.
|
@@ -35,8 +35,8 @@ __export(loadConfig_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(loadConfig_exports);
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_node_bundle_require = require("@modern-js/node-bundle-require");
|
|
39
38
|
var import_utils = require("@modern-js/utils");
|
|
39
|
+
var import_jiti = __toESM(require("jiti"));
|
|
40
40
|
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
41
41
|
const json = JSON.parse(import_utils.fs.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8"));
|
|
42
42
|
return json[packageJsonConfig];
|
|
@@ -64,19 +64,19 @@ const clearFilesOverTime = async (targetDir, overtime) => {
|
|
|
64
64
|
} catch (err) {
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
function loadConfigContent(configFile) {
|
|
68
|
+
const _require = (0, import_jiti.default)(__filename, {
|
|
69
|
+
esmResolve: true,
|
|
70
|
+
// disable require cache to support restart CLI and read the new config
|
|
71
|
+
requireCache: false,
|
|
72
|
+
interopDefault: true
|
|
73
|
+
});
|
|
74
|
+
if (!import_utils.fs.existsSync(configFile)) {
|
|
75
|
+
throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
76
|
+
}
|
|
68
77
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
getOutputFile: async (filePath) => {
|
|
72
|
-
const defaultOutputFileName = import_path.default.basename(await (0, import_node_bundle_require.defaultGetOutputFile)(filePath));
|
|
73
|
-
const outputPath = import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR);
|
|
74
|
-
const timeLimit = 10 * 60;
|
|
75
|
-
await clearFilesOverTime(outputPath, timeLimit);
|
|
76
|
-
return import_path.default.join(outputPath, defaultOutputFileName);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return mod;
|
|
78
|
+
const config = _require(configFile);
|
|
79
|
+
return config.default || config;
|
|
80
80
|
} catch (e) {
|
|
81
81
|
if (e instanceof Error) {
|
|
82
82
|
e.message = `Get Error while loading config file: ${configFile}, please check it and retry.
|
|
@@ -84,7 +84,7 @@ ${e.message || ""}`;
|
|
|
84
84
|
}
|
|
85
85
|
throw e;
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
|
|
89
89
|
let pkgConfig;
|
|
90
90
|
if (packageJsonConfig) {
|
|
@@ -93,11 +93,7 @@ const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
|
|
|
93
93
|
const packageName = require(import_path.default.resolve(appDirectory, "./package.json")).name;
|
|
94
94
|
let config;
|
|
95
95
|
if (configFile) {
|
|
96
|
-
|
|
97
|
-
const mod = await bundleRequireWithCatch(configFile, {
|
|
98
|
-
appDirectory
|
|
99
|
-
});
|
|
100
|
-
config = mod.default || mod;
|
|
96
|
+
config = loadConfigContent(configFile);
|
|
101
97
|
}
|
|
102
98
|
return {
|
|
103
99
|
packageName,
|
|
@@ -2,8 +2,8 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { fs, globby } from "@modern-js/utils";
|
|
6
|
+
import jiti from "jiti";
|
|
7
7
|
var getPackageConfig = function(appDirectory, packageJsonConfig) {
|
|
8
8
|
var json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
|
|
9
9
|
return json[packageJsonConfig];
|
|
@@ -81,121 +81,46 @@ var clearFilesOverTime = function() {
|
|
|
81
81
|
return _ref.apply(this, arguments);
|
|
82
82
|
};
|
|
83
83
|
}();
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
appDirectory = param.appDirectory;
|
|
91
|
-
_state.label = 1;
|
|
92
|
-
case 1:
|
|
93
|
-
_state.trys.push([
|
|
94
|
-
1,
|
|
95
|
-
3,
|
|
96
|
-
,
|
|
97
|
-
4
|
|
98
|
-
]);
|
|
99
|
-
return [
|
|
100
|
-
4,
|
|
101
|
-
bundleRequire(configFile, {
|
|
102
|
-
autoClear: false,
|
|
103
|
-
getOutputFile: function() {
|
|
104
|
-
var _ref2 = _async_to_generator(function(filePath) {
|
|
105
|
-
var defaultOutputFileName, _, outputPath, timeLimit;
|
|
106
|
-
return _ts_generator(this, function(_state2) {
|
|
107
|
-
switch (_state2.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
_ = path.basename;
|
|
110
|
-
return [
|
|
111
|
-
4,
|
|
112
|
-
defaultGetOutputFile(filePath)
|
|
113
|
-
];
|
|
114
|
-
case 1:
|
|
115
|
-
defaultOutputFileName = _.apply(path, [
|
|
116
|
-
_state2.sent()
|
|
117
|
-
]);
|
|
118
|
-
outputPath = path.join(appDirectory, CONFIG_CACHE_DIR);
|
|
119
|
-
timeLimit = 10 * 60;
|
|
120
|
-
return [
|
|
121
|
-
4,
|
|
122
|
-
clearFilesOverTime(outputPath, timeLimit)
|
|
123
|
-
];
|
|
124
|
-
case 2:
|
|
125
|
-
_state2.sent();
|
|
126
|
-
return [
|
|
127
|
-
2,
|
|
128
|
-
path.join(outputPath, defaultOutputFileName)
|
|
129
|
-
];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
return function(filePath) {
|
|
134
|
-
return _ref2.apply(this, arguments);
|
|
135
|
-
};
|
|
136
|
-
}()
|
|
137
|
-
})
|
|
138
|
-
];
|
|
139
|
-
case 2:
|
|
140
|
-
mod = _state.sent();
|
|
141
|
-
return [
|
|
142
|
-
2,
|
|
143
|
-
mod
|
|
144
|
-
];
|
|
145
|
-
case 3:
|
|
146
|
-
e = _state.sent();
|
|
147
|
-
if (_instanceof(e, Error)) {
|
|
148
|
-
e.message = "Get Error while loading config file: ".concat(configFile, ", please check it and retry.\n").concat(e.message || "");
|
|
149
|
-
}
|
|
150
|
-
throw e;
|
|
151
|
-
case 4:
|
|
152
|
-
return [
|
|
153
|
-
2
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
84
|
+
function loadConfigContent(configFile) {
|
|
85
|
+
var _require = jiti(__filename, {
|
|
86
|
+
esmResolve: true,
|
|
87
|
+
// disable require cache to support restart CLI and read the new config
|
|
88
|
+
requireCache: false,
|
|
89
|
+
interopDefault: true
|
|
157
90
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
91
|
+
if (!fs.existsSync(configFile)) {
|
|
92
|
+
throw new Error("Configuration file does not exist: ".concat(configFile));
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
var config = _require(configFile);
|
|
96
|
+
return config.default || config;
|
|
97
|
+
} catch (e) {
|
|
98
|
+
if (_instanceof(e, Error)) {
|
|
99
|
+
e.message = "Get Error while loading config file: ".concat(configFile, ", please check it and retry.\n").concat(e.message || "");
|
|
100
|
+
}
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
162
104
|
var loadConfig = function() {
|
|
163
105
|
var _ref = _async_to_generator(function(appDirectory, configFile, packageJsonConfig) {
|
|
164
|
-
var pkgConfig, packageName, config
|
|
106
|
+
var pkgConfig, packageName, config;
|
|
165
107
|
return _ts_generator(this, function(_state) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (!configFile)
|
|
173
|
-
return [
|
|
174
|
-
3,
|
|
175
|
-
2
|
|
176
|
-
];
|
|
177
|
-
delete require.cache[configFile];
|
|
178
|
-
return [
|
|
179
|
-
4,
|
|
180
|
-
bundleRequireWithCatch(configFile, {
|
|
181
|
-
appDirectory
|
|
182
|
-
})
|
|
183
|
-
];
|
|
184
|
-
case 1:
|
|
185
|
-
mod = _state.sent();
|
|
186
|
-
config = mod.default || mod;
|
|
187
|
-
_state.label = 2;
|
|
188
|
-
case 2:
|
|
189
|
-
return [
|
|
190
|
-
2,
|
|
191
|
-
{
|
|
192
|
-
packageName,
|
|
193
|
-
configFile,
|
|
194
|
-
config,
|
|
195
|
-
pkgConfig
|
|
196
|
-
}
|
|
197
|
-
];
|
|
108
|
+
if (packageJsonConfig) {
|
|
109
|
+
pkgConfig = getPackageConfig(appDirectory, packageJsonConfig);
|
|
110
|
+
}
|
|
111
|
+
packageName = require(path.resolve(appDirectory, "./package.json")).name;
|
|
112
|
+
if (configFile) {
|
|
113
|
+
config = loadConfigContent(configFile);
|
|
198
114
|
}
|
|
115
|
+
return [
|
|
116
|
+
2,
|
|
117
|
+
{
|
|
118
|
+
packageName,
|
|
119
|
+
configFile,
|
|
120
|
+
config,
|
|
121
|
+
pkgConfig
|
|
122
|
+
}
|
|
123
|
+
];
|
|
199
124
|
});
|
|
200
125
|
});
|
|
201
126
|
return function loadConfig2(appDirectory, configFile, packageJsonConfig) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { fs, globby } from "@modern-js/utils";
|
|
3
|
+
import jiti from "jiti";
|
|
4
4
|
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
5
5
|
const json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
|
|
6
6
|
return json[packageJsonConfig];
|
|
@@ -28,19 +28,19 @@ const clearFilesOverTime = async (targetDir, overtime) => {
|
|
|
28
28
|
} catch (err) {
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
function loadConfigContent(configFile) {
|
|
32
|
+
const _require = jiti(__filename, {
|
|
33
|
+
esmResolve: true,
|
|
34
|
+
// disable require cache to support restart CLI and read the new config
|
|
35
|
+
requireCache: false,
|
|
36
|
+
interopDefault: true
|
|
37
|
+
});
|
|
38
|
+
if (!fs.existsSync(configFile)) {
|
|
39
|
+
throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
40
|
+
}
|
|
32
41
|
try {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
getOutputFile: async (filePath) => {
|
|
36
|
-
const defaultOutputFileName = path.basename(await defaultGetOutputFile(filePath));
|
|
37
|
-
const outputPath = path.join(appDirectory, CONFIG_CACHE_DIR);
|
|
38
|
-
const timeLimit = 10 * 60;
|
|
39
|
-
await clearFilesOverTime(outputPath, timeLimit);
|
|
40
|
-
return path.join(outputPath, defaultOutputFileName);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return mod;
|
|
42
|
+
const config = _require(configFile);
|
|
43
|
+
return config.default || config;
|
|
44
44
|
} catch (e) {
|
|
45
45
|
if (e instanceof Error) {
|
|
46
46
|
e.message = `Get Error while loading config file: ${configFile}, please check it and retry.
|
|
@@ -48,7 +48,7 @@ ${e.message || ""}`;
|
|
|
48
48
|
}
|
|
49
49
|
throw e;
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
|
|
53
53
|
let pkgConfig;
|
|
54
54
|
if (packageJsonConfig) {
|
|
@@ -57,11 +57,7 @@ const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
|
|
|
57
57
|
const packageName = require(path.resolve(appDirectory, "./package.json")).name;
|
|
58
58
|
let config;
|
|
59
59
|
if (configFile) {
|
|
60
|
-
|
|
61
|
-
const mod = await bundleRequireWithCatch(configFile, {
|
|
62
|
-
appDirectory
|
|
63
|
-
});
|
|
64
|
-
config = mod.default || mod;
|
|
60
|
+
config = loadConfigContent(configFile);
|
|
65
61
|
}
|
|
66
62
|
return {
|
|
67
63
|
packageName,
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-nightly-
|
|
18
|
+
"version": "0.0.0-nightly-20250123160326",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"jiti": "1.21.7",
|
|
66
67
|
"@swc/helpers": "0.5.13",
|
|
67
|
-
"@modern-js/
|
|
68
|
-
"@modern-js/utils": "0.0.0-nightly-
|
|
69
|
-
"@modern-js/runtime-utils": "0.0.0-nightly-20250122164656"
|
|
68
|
+
"@modern-js/utils": "0.0.0-nightly-20250123160326",
|
|
69
|
+
"@modern-js/runtime-utils": "0.0.0-nightly-20250123160326"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@rsbuild/core": "1.1.13",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"@types/node": "^14",
|
|
76
76
|
"jest": "^29",
|
|
77
77
|
"typescript": "^5",
|
|
78
|
-
"@modern-js/types": "0.0.0-nightly-
|
|
79
|
-
"@modern-js/uni-builder": "0.0.0-nightly-
|
|
80
|
-
"@scripts/
|
|
81
|
-
"@scripts/
|
|
78
|
+
"@modern-js/types": "0.0.0-nightly-20250123160326",
|
|
79
|
+
"@modern-js/uni-builder": "0.0.0-nightly-20250123160326",
|
|
80
|
+
"@scripts/jest-config": "0.0.0-nightly-20250123160326",
|
|
81
|
+
"@scripts/build": "0.0.0-nightly-20250123160326"
|
|
82
82
|
},
|
|
83
83
|
"sideEffects": false,
|
|
84
84
|
"publishConfig": {
|