@modern-js/module-tools 2.15.0 → 2.16.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/CHANGELOG.md +38 -0
- package/compiled/postcss-custom-properties/index.js +1 -1
- package/compiled/postcss-custom-properties/package.json +1 -1
- package/dist/build.js +23 -66
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +114 -170
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +23 -65
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +83 -164
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +15 -28
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +46 -120
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +82 -141
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +34 -85
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +40 -93
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +35 -84
- package/dist/cli.js.map +1 -1
- package/dist/command.js +56 -136
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +13 -42
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +96 -52
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +73 -149
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +36 -0
- package/dist/config/schema.js +118 -56
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +152 -203
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +15 -27
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +71 -84
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +28 -30
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +13 -28
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +27 -30
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +33 -49
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +15 -33
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +45 -91
- package/dist/dev.js.map +1 -1
- package/dist/error.js +37 -54
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +22 -35
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +15 -33
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +15 -42
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +10 -28
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +21 -35
- package/dist/index.js.map +1 -1
- package/dist/locale/en.d.ts +7 -2
- package/dist/locale/en.js +25 -32
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +14 -4
- package/dist/locale/index.js +18 -31
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.d.ts +7 -2
- package/dist/locale/zh.js +25 -32
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +16 -39
- package/dist/plugins.js.map +1 -1
- package/dist/types/color.js +4 -15
- package/dist/types/color.js.map +1 -1
- package/dist/types/command.js +4 -15
- package/dist/types/command.js.map +1 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/config/index.js +6 -17
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.js +4 -15
- package/dist/types/config/style.js.map +1 -1
- package/dist/types/context.js +4 -15
- package/dist/types/context.js.map +1 -1
- package/dist/types/copy.js +4 -15
- package/dist/types/copy.js.map +1 -1
- package/dist/types/dts.js +4 -15
- package/dist/types/dts.js.map +1 -1
- package/dist/types/hooks.js +4 -15
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/index.js +11 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/legacyConfig/index.js +4 -15
- package/dist/types/legacyConfig/index.js.map +1 -1
- package/dist/types/legacyConfig/output.js +4 -15
- package/dist/types/legacyConfig/output.js.map +1 -1
- package/dist/types/legacyConfig/source.js +4 -15
- package/dist/types/legacyConfig/source.js.map +1 -1
- package/dist/types/legacyConfig/tools.js +4 -15
- package/dist/types/legacyConfig/tools.js.map +1 -1
- package/dist/types/utils.js +4 -17
- package/dist/utils/builder.d.ts +20 -2
- package/dist/utils/builder.js +81 -68
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +10 -44
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +108 -144
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +16 -59
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +69 -146
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +44 -87
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +15 -60
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +27 -67
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +14 -61
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +14 -61
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +13 -59
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +57 -105
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +54 -106
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +44 -81
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +25 -20
- package/scripts/debug-mode.js +23 -21
- package/dist/types/utils.js.map +0 -1
package/dist/utils/dts.js
CHANGED
|
@@ -1,98 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
25
6
|
for (var name in all)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
-
mod
|
|
43
|
-
));
|
|
44
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
-
var __async = (__this, __arguments, generator) => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
var fulfilled = (value) => {
|
|
48
|
-
try {
|
|
49
|
-
step(generator.next(value));
|
|
50
|
-
} catch (e) {
|
|
51
|
-
reject(e);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var rejected = (value) => {
|
|
55
|
-
try {
|
|
56
|
-
step(generator.throw(value));
|
|
57
|
-
} catch (e) {
|
|
58
|
-
reject(e);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
var dts_exports = {};
|
|
66
|
-
__export(dts_exports, {
|
|
67
|
-
assignTsConfigPath: () => assignTsConfigPath,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
68
13
|
generatorTsConfig: () => generatorTsConfig,
|
|
69
14
|
getTscBinPath: () => getTscBinPath,
|
|
70
|
-
|
|
71
|
-
|
|
15
|
+
resolveAlias: () => resolveAlias,
|
|
16
|
+
assignTsConfigPath: () => assignTsConfigPath,
|
|
17
|
+
printOrThrowDtsErrors: () => printOrThrowDtsErrors
|
|
72
18
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const {
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
22
|
+
const generatorTsConfig = async (config) => {
|
|
23
|
+
const { fs, nanoid } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
24
|
+
const { dtsTempDirectory } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
|
|
78
25
|
const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
|
|
79
|
-
const tempDistAbsRootPath =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
const tempDistAbsOurDir = import_path.default.join(
|
|
84
|
-
tempDistAbsRootPath,
|
|
85
|
-
import_path.default.relative(appDirectory, absSourceDir)
|
|
86
|
-
);
|
|
87
|
-
const tempTsconfigPath = import_path.default.join(
|
|
88
|
-
tempDistAbsRootPath,
|
|
89
|
-
import_path.default.basename(tsconfigPath)
|
|
90
|
-
);
|
|
26
|
+
const tempDistAbsRootPath = _path.default.join(appDirectory, `${dtsTempDirectory}/${nanoid()}`);
|
|
27
|
+
const tempDistAbsOurDir = _path.default.join(tempDistAbsRootPath, _path.default.relative(appDirectory, absSourceDir));
|
|
28
|
+
const tempTsconfigPath = _path.default.join(tempDistAbsRootPath, _path.default.basename(tsconfigPath));
|
|
91
29
|
fs.ensureFileSync(tempTsconfigPath);
|
|
92
|
-
const extendsPath =
|
|
93
|
-
import_path.default.relative(import_path.default.dirname(tempTsconfigPath), import_path.default.dirname(tsconfigPath)),
|
|
94
|
-
import_path.default.basename(tempTsconfigPath)
|
|
95
|
-
);
|
|
30
|
+
const extendsPath = _path.default.join(_path.default.relative(_path.default.dirname(tempTsconfigPath), _path.default.dirname(tsconfigPath)), _path.default.basename(tempTsconfigPath));
|
|
96
31
|
const resetConfig = {
|
|
97
32
|
extends: extendsPath,
|
|
98
33
|
compilerOptions: {
|
|
@@ -113,89 +48,77 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
|
|
|
113
48
|
tempDistAbsRootPath,
|
|
114
49
|
tempDistAbsSrcPath: tempDistAbsOurDir
|
|
115
50
|
};
|
|
116
|
-
}
|
|
117
|
-
const getTscBinPath = (appDirectory) =>
|
|
118
|
-
const { fs } =
|
|
119
|
-
const { default: findUp, exists: pathExists } =
|
|
120
|
-
const tscBinFile =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
51
|
+
};
|
|
52
|
+
const getTscBinPath = async (appDirectory) => {
|
|
53
|
+
const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
54
|
+
const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/find-up")));
|
|
55
|
+
const tscBinFile = await findUp(async (directory) => {
|
|
56
|
+
const targetFilePath = _path.default.join(directory, "./node_modules/.bin/tsc");
|
|
57
|
+
const hasTscBinFile = await pathExists(targetFilePath);
|
|
58
|
+
if (hasTscBinFile) {
|
|
59
|
+
return targetFilePath;
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
}, {
|
|
63
|
+
cwd: appDirectory
|
|
64
|
+
});
|
|
131
65
|
if (!tscBinFile || !fs.existsSync(tscBinFile)) {
|
|
132
|
-
throw new Error(
|
|
133
|
-
"Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory."
|
|
134
|
-
);
|
|
66
|
+
throw new Error("Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.");
|
|
135
67
|
}
|
|
136
68
|
return tscBinFile;
|
|
137
|
-
}
|
|
138
|
-
const resolveAlias =
|
|
139
|
-
var
|
|
69
|
+
};
|
|
70
|
+
const resolveAlias = async (config, options, watchFilenames = []) => {
|
|
71
|
+
var _userTsconfig_compilerOptions;
|
|
140
72
|
const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
|
|
141
|
-
const { globby, fs } =
|
|
142
|
-
const { transformDtsAlias } =
|
|
73
|
+
const { globby, fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
74
|
+
const { transformDtsAlias } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./tspathsTransform")));
|
|
143
75
|
const { distAbsPath } = config;
|
|
144
76
|
const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
|
|
145
|
-
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, {
|
|
77
|
+
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, {
|
|
78
|
+
absolute: true
|
|
79
|
+
});
|
|
80
|
+
var _userTsconfig_compilerOptions_paths;
|
|
146
81
|
const result = transformDtsAlias({
|
|
147
82
|
filenames: dtsFilenames,
|
|
148
83
|
baseUrl: tempDistAbsRootPath,
|
|
149
|
-
paths: (
|
|
84
|
+
paths: (_userTsconfig_compilerOptions_paths = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.paths) !== null && _userTsconfig_compilerOptions_paths !== void 0 ? _userTsconfig_compilerOptions_paths : {}
|
|
150
85
|
});
|
|
151
86
|
for (const r of result) {
|
|
152
87
|
fs.writeFileSync(r.path, r.content);
|
|
153
88
|
}
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
const assignTsConfigPath = (config, options) =>
|
|
157
|
-
|
|
158
|
-
const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
89
|
+
await fs.copy(tempDistAbsSrcPath, distAbsPath);
|
|
90
|
+
};
|
|
91
|
+
const assignTsConfigPath = async (config, options) => {
|
|
92
|
+
const { defaultTsConfigPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
|
|
159
93
|
if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
|
|
160
|
-
|
|
94
|
+
var _config_dts;
|
|
95
|
+
config.dts = {
|
|
161
96
|
only: false,
|
|
162
97
|
distPath: "./",
|
|
163
|
-
abortOnError: true
|
|
164
|
-
|
|
98
|
+
abortOnError: true,
|
|
99
|
+
...(_config_dts = config.dts) !== null && _config_dts !== void 0 ? _config_dts : {},
|
|
165
100
|
tsconfigPath: options.tsconfig
|
|
166
|
-
}
|
|
101
|
+
};
|
|
167
102
|
}
|
|
168
103
|
return config;
|
|
169
|
-
}
|
|
170
|
-
const printOrThrowDtsErrors = (error, options) =>
|
|
171
|
-
const { logger, chalk } =
|
|
172
|
-
const { InternalDTSError } =
|
|
173
|
-
const local =
|
|
174
|
-
const { abortOnError, buildType } = options
|
|
104
|
+
};
|
|
105
|
+
const printOrThrowDtsErrors = async (error, options) => {
|
|
106
|
+
const { logger, chalk } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
107
|
+
const { InternalDTSError } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../error")));
|
|
108
|
+
const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
|
|
109
|
+
const { abortOnError, buildType } = options !== null && options !== void 0 ? options : {};
|
|
175
110
|
if (error instanceof Error) {
|
|
176
111
|
if (abortOnError) {
|
|
177
112
|
throw new InternalDTSError(error, {
|
|
178
113
|
buildType
|
|
179
114
|
});
|
|
180
115
|
} else {
|
|
181
|
-
logger.warn(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
new InternalDTSError(error, {
|
|
186
|
-
buildType
|
|
187
|
-
})
|
|
188
|
-
);
|
|
116
|
+
logger.warn(chalk.bgYellowBright(local.i18n.t(local.localeKeys.warns.dts.abortOnError)));
|
|
117
|
+
logger.error(new InternalDTSError(error, {
|
|
118
|
+
buildType
|
|
119
|
+
}));
|
|
189
120
|
}
|
|
190
121
|
}
|
|
191
|
-
}
|
|
192
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
193
|
-
0 && (module.exports = {
|
|
194
|
-
assignTsConfigPath,
|
|
195
|
-
generatorTsConfig,
|
|
196
|
-
getTscBinPath,
|
|
197
|
-
printOrThrowDtsErrors,
|
|
198
|
-
resolveAlias
|
|
199
|
-
});
|
|
122
|
+
};
|
|
200
123
|
|
|
201
124
|
//# sourceMappingURL=dts.js.map
|
package/dist/utils/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":"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","names":["generatorTsConfig","getTscBinPath","resolveAlias","assignTsConfigPath","printOrThrowDtsErrors","config","fs","nanoid","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","globby","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","copy","defaultTsConfigPath","tsconfig","dts","only","distPath","abortOnError","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
|
package/dist/utils/input.js
CHANGED
|
@@ -1,127 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var input_exports = {};
|
|
49
|
-
__export(input_exports, {
|
|
50
|
-
addInputToPreset: () => addInputToPreset,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
joinPathWithPrefix: () => joinPathWithPrefix,
|
|
51
14
|
getAbsInput: () => getAbsInput,
|
|
15
|
+
addInputToPreset: () => addInputToPreset,
|
|
52
16
|
getDefaultIndexEntry: () => getDefaultIndexEntry,
|
|
53
|
-
joinPathWithPrefix: () => joinPathWithPrefix,
|
|
54
17
|
normalizeInput: () => normalizeInput
|
|
55
18
|
});
|
|
56
|
-
|
|
57
|
-
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
58
22
|
const joinPathWithPrefix = (flag) => (p1, globPath) => {
|
|
59
23
|
const haveFlag = globPath.trim().startsWith(flag);
|
|
60
24
|
if (haveFlag) {
|
|
61
|
-
return
|
|
25
|
+
return _path.default.join(flag, p1, globPath.replace(flag, ""));
|
|
62
26
|
}
|
|
63
|
-
return
|
|
27
|
+
return _path.default.join(p1, globPath);
|
|
64
28
|
};
|
|
65
|
-
const getAbsInput = (entry, options) =>
|
|
66
|
-
const { slash } =
|
|
29
|
+
const getAbsInput = async (entry, options) => {
|
|
30
|
+
const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
67
31
|
const { appDirectory } = options;
|
|
68
32
|
const resolvePathWithNoMatchFlag = joinPathWithPrefix("!");
|
|
69
33
|
if (Array.isArray(entry)) {
|
|
70
|
-
return entry.map(
|
|
71
|
-
(p) => import_path.default.isAbsolute(p) ? slash(p) : slash(resolvePathWithNoMatchFlag(appDirectory, p))
|
|
72
|
-
);
|
|
34
|
+
return entry.map((p) => _path.default.isAbsolute(p) ? slash(p) : slash(resolvePathWithNoMatchFlag(appDirectory, p)));
|
|
73
35
|
}
|
|
74
36
|
const newEntry = {};
|
|
75
37
|
for (const key of Object.keys(entry)) {
|
|
76
|
-
newEntry[key] =
|
|
38
|
+
newEntry[key] = _path.default.isAbsolute(entry[key]) ? slash(entry[key]) : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));
|
|
77
39
|
}
|
|
78
40
|
return newEntry;
|
|
79
|
-
}
|
|
80
|
-
const addInputToPreset = (config, context) =>
|
|
41
|
+
};
|
|
42
|
+
const addInputToPreset = async (config, context) => {
|
|
81
43
|
if (Array.isArray(config)) {
|
|
82
44
|
for (const c of config) {
|
|
83
45
|
if (c.buildType === "bundle") {
|
|
84
|
-
c.input =
|
|
46
|
+
c.input = await getDefaultIndexEntry(context);
|
|
85
47
|
} else if (c.buildType === "bundleless") {
|
|
86
48
|
c.sourceDir = "./src";
|
|
87
49
|
}
|
|
88
50
|
}
|
|
89
51
|
} else if (config.buildType === "bundle") {
|
|
90
|
-
config.input =
|
|
52
|
+
config.input = await getDefaultIndexEntry(context);
|
|
91
53
|
} else if (config.buildType === "bundleless") {
|
|
92
54
|
config.sourceDir = "./src";
|
|
93
55
|
}
|
|
94
56
|
return config;
|
|
95
|
-
}
|
|
96
|
-
const getDefaultIndexEntry =
|
|
97
|
-
|
|
98
|
-
appDirectory
|
|
99
|
-
}) {
|
|
100
|
-
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
101
|
-
let entry = isTsProject ? import_path.default.join(appDirectory, "./src/index.ts") : import_path.default.join(appDirectory, "./src/index.js");
|
|
57
|
+
};
|
|
58
|
+
const getDefaultIndexEntry = async ({ isTsProject, appDirectory }) => {
|
|
59
|
+
const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
60
|
+
let entry = isTsProject ? _path.default.join(appDirectory, "./src/index.ts") : _path.default.join(appDirectory, "./src/index.js");
|
|
102
61
|
if (fs.existsSync(entry)) {
|
|
103
|
-
return [
|
|
62
|
+
return [
|
|
63
|
+
`./${_path.default.relative(appDirectory, entry)}`
|
|
64
|
+
];
|
|
104
65
|
}
|
|
105
|
-
entry = isTsProject ?
|
|
66
|
+
entry = isTsProject ? _path.default.join(appDirectory, "./src/index.tsx") : _path.default.join(appDirectory, "./src/index.jsx");
|
|
106
67
|
if (fs.existsSync(entry)) {
|
|
107
|
-
return [
|
|
68
|
+
return [
|
|
69
|
+
`./${_path.default.relative(appDirectory, entry)}`
|
|
70
|
+
];
|
|
108
71
|
}
|
|
109
72
|
return [];
|
|
110
|
-
}
|
|
111
|
-
const normalizeInput = (baseConfig, options) =>
|
|
73
|
+
};
|
|
74
|
+
const normalizeInput = async (baseConfig, options) => {
|
|
112
75
|
if (baseConfig.buildType === "bundleless" && !baseConfig.input) {
|
|
113
|
-
const { slash } =
|
|
114
|
-
return [
|
|
76
|
+
const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
77
|
+
return [
|
|
78
|
+
slash(baseConfig.sourceDir)
|
|
79
|
+
];
|
|
115
80
|
}
|
|
116
81
|
return getAbsInput(baseConfig.input, options);
|
|
117
|
-
}
|
|
118
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
-
0 && (module.exports = {
|
|
120
|
-
addInputToPreset,
|
|
121
|
-
getAbsInput,
|
|
122
|
-
getDefaultIndexEntry,
|
|
123
|
-
joinPathWithPrefix,
|
|
124
|
-
normalizeInput
|
|
125
|
-
});
|
|
82
|
+
};
|
|
126
83
|
|
|
127
84
|
//# sourceMappingURL=input.js.map
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB,MAAlBA;EAUAC,aAAW,MAAXA;EAsBAC,kBAAgB,MAAhBA;EAqBAC,sBAAoB,MAApBA;EAyBAC,gBAAc,MAAdA;;;;iEA1FI;AAYV,MAAMJ,qBACX,CAACK,SAAiB,CAACC,IAAYC,aAAqB;AAClD,QAAMC,WAAWD,SAASE,KAAI,EAAGC,WAAWL;AAC5C,MAAIG,UAAU;AACZ,WAAOG,cAAKC,KAAKP,MAAMC,IAAIC,SAASM,QAAQR,MAAM;EACpD;AAEA,SAAOM,cAAKC,KAAKN,IAAIC;AACvB;AAEK,MAAMN,cAAc,OAAOa,OAAcC,YAA0B;AACxE,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,QAAM,EAAEC,aAAY,IAAKF;AACzB,QAAMG,6BAA6BlB,mBAAmB;AAEtD,MAAImB,MAAMC,QAAQN,QAAQ;AACxB,WAAOA,MAAMO,IAAIC,OACfX,cAAKY,WAAWD,KACZN,MAAMM,KACNN,MAAME,2BAA2BD,cAAcK,GAAG;EAE1D;AAEA,QAAME,WAAmC,CAAC;AAC1C,aAAWC,OAAOC,OAAOC,KAAKb,QAAQ;AACpCU,aAASC,OAAOd,cAAKY,WAAWT,MAAMW,IAAI,IACtCT,MAAMF,MAAMW,IAAI,IAChBT,MAAME,2BAA2BD,cAAcH,MAAMW,IAAI;EAC/D;AACA,SAAOD;AACT;AAEO,MAAMtB,mBAAmB,OAC9B0B,QACAC,YACG;AACH,MAAIV,MAAMC,QAAQQ,SAAS;AACzB,eAAWE,KAAKF,QAAQ;AACtB,UAAIE,EAAEC,cAAc,UAAU;AAC5BD,UAAEE,QAAQ,MAAM7B,qBAAqB0B;MACvC,WAAWC,EAAEC,cAAc,cAAc;AACvCD,UAAEG,YAAY;MAChB;IACF;EACF,WAAWL,OAAOG,cAAc,UAAU;AACxCH,WAAOI,QAAQ,MAAM7B,qBAAqB0B;EAC5C,WAAWD,OAAOG,cAAc,cAAc;AAC5CH,WAAOK,YAAY;EACrB;AAEA,SAAOL;AACT;AAEO,MAAMzB,uBAAuB,OAAO,EACzC+B,aACAjB,aAAY,MAIR;AACJ,QAAM,EAAEkB,GAAE,IAAK,MAAM,iFAAO;AAC5B,MAAIrB,QAAQoB,cACRvB,cAAKC,KAAKK,cAAc,oBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEAA,UAAQoB,cACJvB,cAAKC,KAAKK,cAAc,qBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEA,SAAO;AACT;AAEO,MAAMV,iBAAiB,OAC5BkC,YACAvB,YACG;AACH,MAAIuB,WAAWP,cAAc,gBAAgB,CAACO,WAAWN,OAAO;AAC9D,UAAM,EAAEhB,MAAK,IAAK,MAAM,iFAAO;AAC/B,WAAO;MAACA,MAAMsB,WAAWL,SAAS;;EACpC;AACA,SAAOhC,YAAYqC,WAAWN,OAAOjB;AACvC;","names":["joinPathWithPrefix","getAbsInput","addInputToPreset","getDefaultIndexEntry","normalizeInput","flag","p1","globPath","haveFlag","trim","startsWith","path","join","replace","entry","options","slash","appDirectory","resolvePathWithNoMatchFlag","Array","isArray","map","p","isAbsolute","newEntry","key","Object","keys","config","context","c","buildType","input","sourceDir","isTsProject","fs","existsSync","relative","baseConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
|
package/dist/utils/language.js
CHANGED
|
@@ -1,65 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var language_exports = {};
|
|
49
|
-
__export(language_exports, {
|
|
50
|
-
initLocalLanguage: () => initLocalLanguage
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initLocalLanguage", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => initLocalLanguage
|
|
51
8
|
});
|
|
52
|
-
|
|
53
|
-
const initLocalLanguage = () =>
|
|
54
|
-
const local =
|
|
55
|
-
const { getLocaleLanguage } =
|
|
9
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
|
+
const initLocalLanguage = async () => {
|
|
11
|
+
const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
|
|
12
|
+
const { getLocaleLanguage } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/plugin-i18n/language-detector")));
|
|
56
13
|
const locale = getLocaleLanguage();
|
|
57
|
-
local.i18n.changeLanguage({
|
|
14
|
+
local.i18n.changeLanguage({
|
|
15
|
+
locale
|
|
16
|
+
});
|
|
58
17
|
return local;
|
|
59
|
-
}
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
initLocalLanguage
|
|
63
|
-
});
|
|
18
|
+
};
|
|
64
19
|
|
|
65
20
|
//# sourceMappingURL=language.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,YAAY;AAC3C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAEF,QAAMC,SAASD;AACfD,QAAMG,KAAKC,eAAe;IAAEF;EAAO;AACnC,SAAOF;AACT;","names":["initLocalLanguage","local","getLocaleLanguage","locale","i18n","changeLanguage"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/language.ts"],"sourcesContent":["export const initLocalLanguage = async () => {\n const local = await import('../locale');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
|