@plaudit/webpack-extensions 2.82.1 → 2.82.3

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/build/shared.d.ts CHANGED
@@ -133,7 +133,7 @@ export type MinimumViableMetadata = {
133
133
  };
134
134
  export declare function convertUsageLocationsHandleToEmittableHandle(handle: UsageLocations['handle'], generatedHandle: string): string;
135
135
  export declare function makeEmittableConfigPHP(data: any, asFullFile: boolean, parentIndent?: string): string;
136
- export declare const entrypointFields: readonly ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule", "scriptModule"];
136
+ export declare const entrypointFields: readonly ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"];
137
137
  export type EntrypointFields = (typeof entrypointFields[number])[];
138
138
  export declare function convertEntrypointFieldForAssetType(entrypointField: EntrypointFields[number], assetType: 'script' | 'style'): EntrypointFields[number];
139
139
  export declare function leadingSlashIt(pathOrSomething: string): string;
@@ -143,7 +143,7 @@ export declare const scriptWithModuleExtension: RegExp;
143
143
  export declare const styleExtension: RegExp;
144
144
  export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "style" | "script" | "";
145
145
  export declare function isStyleField(field: string): field is 'style' | 'viewStyle' | 'editorStyle';
146
- export declare function isScriptModuleField(field: string): field is 'scriptModule' | 'viewScriptModule';
146
+ export declare function isScriptModuleField(field: string): field is 'viewScriptModule';
147
147
  export declare function getHandleGroup(field: string): 'styleHandles' | 'scriptHandles' | 'scriptModuleHandles';
148
148
  export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
149
149
  export type TupleOf<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
package/build/shared.js CHANGED
@@ -89,10 +89,10 @@ function makeEmittableConfigPHP(data, asFullFile, parentIndent = "") {
89
89
  .replaceAll(/'rest' => \[\n\t+(\[(?:'[^']+')?]),\n\t+('[^']+')(?:,\n\t+(\[[^\n]+]))?\n\t+]/gs, (_, deps, hash, args) => `'rest' => [${[deps, hash, args].filter(value => !!value).join(", ")}]`);
90
90
  return asFullFile ? `<?php return ${prettyPrintedMetadata};` : prettyPrintedMetadata.trim();
91
91
  }
92
- exports.entrypointFields = ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule", "scriptModule"];
92
+ exports.entrypointFields = ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"];
93
93
  function convertEntrypointFieldForAssetType(entrypointField, assetType) {
94
94
  // Using these word fragments instead of the full words allows us to avoid having to deal with the capitalization of the first letter
95
- const searchRep = assetType === 'script' ? ['tyle', 'cript'] : ['cript', 'tyle'];
95
+ const searchRep = assetType === 'script' ? ['tyle', 'cript'] : [/cript(?:Module)?/, 'tyle'];
96
96
  return entrypointField.replace(...searchRep);
97
97
  }
98
98
  function leadingSlashIt(pathOrSomething) {
@@ -189,10 +189,9 @@ function getAssetsJson(compilation) {
189
189
  function getParsedAssetsJsonDataForEntrypoint(compilation, entrypoint, metadata) {
190
190
  const dest = metadata.dest;
191
191
  const parsedAssetJson = getAssetsJson(compilation);
192
- const scriptExtension = compilation.outputOptions.module ? exports.scriptWithModuleExtension : exports.scriptWithoutModuleExtension;
193
- const assetType = scriptOrStyleTest(metadata.absoluteSrc, scriptExtension);
192
+ const assetType = scriptOrStyleTest(metadata.absoluteSrc, exports.scriptExtension);
194
193
  const chunkFiles = [dest.destination, ...entrypoint.chunks.flatMap(chunk => Array.from(chunk.files))]
195
- .filter(chunkFile => scriptOrStyleTest(chunkFile, scriptExtension) === assetType);
194
+ .filter(chunkFile => scriptOrStyleTest(chunkFile, exports.scriptExtension) === assetType);
196
195
  for (const chunkFile of chunkFiles) {
197
196
  if (parsedAssetJson[chunkFile]) {
198
197
  return { assetName: chunkFile, assetData: parsedAssetJson[chunkFile] };
@@ -36,7 +36,7 @@ function mapToRealEntrypoints(entrypoint, dir, supportedExtensions, args) {
36
36
  .filter(ep => supportedExtensions(ep) && node_fs_1.default.statSync(ep, { throwIfNoEntry: false })?.isFile())
37
37
  .map(ep => {
38
38
  const parsedEntrypoint = node_path_1.default.parse(ep);
39
- const entrypointField = shared_1.styleExtension.test(ep) ? 'style' : shared_1.scriptWithModuleExtension.test(ep) ? 'scriptModule' : 'script';
39
+ const entrypointField = shared_1.styleExtension.test(ep) ? 'style' : shared_1.scriptWithModuleExtension.test(ep) ? 'viewScriptModule' : 'script';
40
40
  const fakeEntrypointInfo = {
41
41
  blockJsonOrigin: args.entrypointJsonOrigin,
42
42
  entrypointField,
@@ -431,7 +431,7 @@ function commonConfigProcessingPrep(config, webpackConfig) {
431
431
  const processingModules = webpackConfig.output?.module ?? false;
432
432
  if (processingModules) {
433
433
  scriptExtension = shared_1.scriptWithModuleExtension;
434
- entrypointFields = ["viewScriptModule", "scriptModule"];
434
+ entrypointFields = ["viewScriptModule"];
435
435
  }
436
436
  else {
437
437
  scriptExtension = shared_1.scriptWithoutModuleExtension;
@@ -467,6 +467,17 @@ function destToKey(dest) {
467
467
  return [dest.assumeGlobalizedPlauditLibraries, dest.bundleAnalyzer, externalize].join("~");
468
468
  }
469
469
  function processIndividualWebpackConfig(config, webpackConfig, sources, canClean) {
470
+ if (webpackConfig.output?.module) {
471
+ // This ensures that module files are emitted as module files
472
+ webpackConfig = {
473
+ ...webpackConfig,
474
+ output: {
475
+ ...webpackConfig.output,
476
+ filename: '[name].mjs',
477
+ chunkFilename: '[name].mjs?ver=[chunkhash]',
478
+ }
479
+ };
480
+ }
470
481
  const commonConfig = commonConfigProcessingPrep(config, webpackConfig);
471
482
  const { processingModules, scriptExtension } = commonConfig;
472
483
  const allSrcRoots = sources.map(([src, dest]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.82.1",
3
+ "version": "2.82.3",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build"