webpack-gc-i18n-plugin 1.1.9 → 1.1.10

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.cjs CHANGED
@@ -3056,9 +3056,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
3056
3056
  const RUNTIME_MANIFEST_VERSION = 1;
3057
3057
  const RUNTIME_MANIFEST_GLOBAL = '__GC_I18N_RUNTIME_MANIFEST__';
3058
3058
  const VITE_RUNTIME_MANIFEST_ID = 'virtual:gc-i18n-runtime-manifest';
3059
- const VITE_RUNTIME_BOOTSTRAP_ID = 'virtual:gc-i18n-runtime-bootstrap';
3060
3059
  const RESOLVED_VITE_RUNTIME_MANIFEST_ID = `\0${VITE_RUNTIME_MANIFEST_ID}`;
3061
- const RESOLVED_VITE_RUNTIME_BOOTSTRAP_ID = `\0${VITE_RUNTIME_BOOTSTRAP_ID}`;
3062
3060
  function normalizeResourcePath(resourcePath, root) {
3063
3061
  if (!resourcePath) return undefined;
3064
3062
  if (!root) return resourcePath;
@@ -3129,44 +3127,6 @@ function createI18nManifestCollector() {
3129
3127
  function serializeRuntimeManifest(manifest) {
3130
3128
  return `const manifest = ${JSON.stringify(manifest, null, 2)};\nexport { manifest };\nexport default manifest;\n`;
3131
3129
  }
3132
- function createRuntimeBootstrapCode() {
3133
- let manifestModuleId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : VITE_RUNTIME_MANIFEST_ID;
3134
- return `import manifest from ${JSON.stringify(manifestModuleId)};\nconst target = typeof globalThis !== 'undefined' ? globalThis : window;\ntarget[${JSON.stringify(RUNTIME_MANIFEST_GLOBAL)}] = manifest;\nexport { manifest };\nexport default manifest;\n`;
3135
- }
3136
- function writeWebpackRuntimeBootstrap(root, manifestAssetName) {
3137
- const outputDir = path.join(root, 'node_modules', '.cache', 'gc-i18n-plugin');
3138
- fs.mkdirSync(outputDir, {
3139
- recursive: true
3140
- });
3141
- const bootstrapPath = path.join(outputDir, 'runtime-bootstrap.js');
3142
- const source = `if (typeof globalThis !== 'undefined') {\n globalThis[${JSON.stringify(RUNTIME_MANIFEST_GLOBAL)}] = globalThis[${JSON.stringify(RUNTIME_MANIFEST_GLOBAL)}] || { version: ${RUNTIME_MANIFEST_VERSION}, resources: [], records: [] };\n globalThis[${JSON.stringify(RUNTIME_MANIFEST_GLOBAL)}].asset = ${JSON.stringify(manifestAssetName)};\n}\n`;
3143
- fs.writeFileSync(bootstrapPath, source);
3144
- return bootstrapPath;
3145
- }
3146
- function prependWebpackEntry(entry, bootstrapPath) {
3147
- if (!entry) return entry;
3148
- if (typeof entry === 'string') return [bootstrapPath, entry];
3149
- if (Array.isArray(entry)) return [bootstrapPath, ...entry];
3150
- if (typeof entry === 'function') {
3151
- return async () => prependWebpackEntry(await entry(), bootstrapPath);
3152
- }
3153
- if (typeof entry === 'object') {
3154
- return Object.fromEntries(Object.entries(entry).map(_ref3 => {
3155
- let [name, value] = _ref3;
3156
- if (typeof value === 'string' || Array.isArray(value)) {
3157
- return [name, prependWebpackEntry(value, bootstrapPath)];
3158
- }
3159
- if (value && typeof value === 'object' && 'import' in value) {
3160
- return [name, {
3161
- ...value,
3162
- import: prependWebpackEntry(value.import, bootstrapPath)
3163
- }];
3164
- }
3165
- return [name, value];
3166
- }));
3167
- }
3168
- return entry;
3169
- }
3170
3130
 
3171
3131
  const RTL_LANGUAGES = new Set(['ar', 'fa', 'he', 'iw', 'ps', 'ur']);
3172
3132
  const DEFAULT_NAMESPACE = 'lang';
@@ -3416,8 +3376,6 @@ var webpackPluginsAutoI18n = /** @class */function () {
3416
3376
  */
3417
3377
  compiler.hooks.environment.tap('webpackPluginsAutoI18n', function () {
3418
3378
  var _a, _b;
3419
- var bootstrapPath = writeWebpackRuntimeBootstrap(compiler.context || process.cwd(), runtimeManifestAssetName);
3420
- compiler.options.entry = prependWebpackEntry(compiler.options.entry, bootstrapPath);
3421
3379
  // 检查 compiler 配置中是否有 module.rules 且没有添加过自定义 Loader
3422
3380
  if (((_a = compiler.options.module) === null || _a === void 0 ? void 0 : _a.rules) && !compiler.options.module.rules.some(hasCustomLoader)) {
3423
3381
  // 向 module.rules 中添加自定义 Loader
@@ -3556,7 +3514,6 @@ exports.FunctionFactoryOption = FunctionFactoryOption;
3556
3514
  exports.GoogleTranslator = GoogleTranslator;
3557
3515
  exports.LanguageEnum = LanguageEnum;
3558
3516
  exports.OriginLangKeyEnum = OriginLangKeyEnum;
3559
- exports.RESOLVED_VITE_RUNTIME_BOOTSTRAP_ID = RESOLVED_VITE_RUNTIME_BOOTSTRAP_ID;
3560
3517
  exports.RESOLVED_VITE_RUNTIME_MANIFEST_ID = RESOLVED_VITE_RUNTIME_MANIFEST_ID;
3561
3518
  exports.RUNTIME_MANIFEST_GLOBAL = RUNTIME_MANIFEST_GLOBAL;
3562
3519
  exports.RUNTIME_MANIFEST_VERSION = RUNTIME_MANIFEST_VERSION;
@@ -3564,7 +3521,6 @@ exports.ScanTranslator = ScanTranslator;
3564
3521
  exports.TranslateApiEnum = TranslateApiEnum;
3565
3522
  exports.TranslateTypeEnum = TranslateTypeEnum;
3566
3523
  exports.Translator = Translator;
3567
- exports.VITE_RUNTIME_BOOTSTRAP_ID = VITE_RUNTIME_BOOTSTRAP_ID;
3568
3524
  exports.VITE_RUNTIME_MANIFEST_ID = VITE_RUNTIME_MANIFEST_ID;
3569
3525
  exports.VolcengineTranslator = VolcengineTranslator;
3570
3526
  exports.Vue2Extends = Vue2Extends;
@@ -3573,16 +3529,13 @@ exports.baseUtils = base;
3573
3529
  exports.checkOption = checkOption;
3574
3530
  exports.createI18nManifestCollector = createI18nManifestCollector;
3575
3531
  exports.createI18nRuntime = createI18nRuntime;
3576
- exports.createRuntimeBootstrapCode = createRuntimeBootstrapCode;
3577
3532
  exports.default = webpackPluginsAutoI18n;
3578
3533
  exports.fileUtils = file;
3579
3534
  exports.filter = index$1;
3580
3535
  exports.initOption = initOption;
3581
3536
  exports.installI18nRuntime = installI18nRuntime;
3582
- exports.prependWebpackEntry = prependWebpackEntry;
3583
3537
  exports.runtimeUtils = runtimeUtils;
3584
3538
  exports.serializeRuntimeManifest = serializeRuntimeManifest;
3585
3539
  exports.translateUtils = translate;
3586
3540
  exports.uploadUtils = upload$1;
3587
- exports.writeWebpackRuntimeBootstrap = writeWebpackRuntimeBootstrap;
3588
3541
  //# sourceMappingURL=index.cjs.map