@ms-cloudpack/esm-stub-utilities 0.13.21 → 0.13.22

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,12 +1,9 @@
1
- export declare const supportedCJSExtensions: string[];
1
+ import type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';
2
2
  /**
3
3
  * Given an (absolute) inputPath and (relative) entryPath, returns an absolute stub path
4
4
  * if a stub should indeed be generated for the entry. Otherwise returns undefined.
5
5
  */
6
- export declare function getStubPath(options: {
7
- inputPath: string;
6
+ export declare function getStubPath(options: Pick<WriteESMStubsOptions, 'inputPath'> & {
8
7
  entryPath: string;
9
- /** Assume the entry is CJS (for testing only) */
10
- forceCJS?: boolean;
11
8
  }): Promise<string | undefined>;
12
9
  //# sourceMappingURL=getStubPath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStubPath.d.ts","sourceRoot":"","sources":["../src/getStubPath.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB,UAAkB,CAAC;AAEtD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoB9B"}
1
+ {"version":3,"file":"getStubPath.d.ts","sourceRoot":"","sources":["../src/getStubPath.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACvE,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqB7B"}
@@ -2,19 +2,19 @@ import path from 'path';
2
2
  import { mkdir } from 'fs/promises';
3
3
  import { detectModuleType } from '@ms-cloudpack/package-utilities';
4
4
  import { slash } from '@ms-cloudpack/path-string-parsing';
5
- export const supportedCJSExtensions = ['.js', '.cjs'];
5
+ import { supportedCjsExtensions, supportedOtherExtensions } from './supportedExtensions.js';
6
6
  /**
7
7
  * Given an (absolute) inputPath and (relative) entryPath, returns an absolute stub path
8
8
  * if a stub should indeed be generated for the entry. Otherwise returns undefined.
9
9
  */
10
10
  export async function getStubPath(options) {
11
- const { inputPath, entryPath, forceCJS } = options;
11
+ const { inputPath, entryPath } = options;
12
12
  const ext = path.extname(entryPath).toLowerCase();
13
- const isCJSEntry = forceCJS ||
14
- (supportedCJSExtensions.includes(ext) && (await detectModuleType(path.resolve(inputPath, entryPath))) === 'cjs');
15
- const isJSONEntry = ext === '.json';
16
- if (isCJSEntry || isJSONEntry) {
17
- const stubFilename = path.basename(entryPath, supportedCJSExtensions.includes(ext) ? ext : undefined) + '-stub.mjs';
13
+ const isMaybeCjs = supportedCjsExtensions.includes(ext);
14
+ if (supportedOtherExtensions.includes(ext) ||
15
+ // detectModuleType will only parse the module if it's .js (ambiguous)
16
+ (isMaybeCjs && (await detectModuleType(path.resolve(inputPath, entryPath))) === 'cjs')) {
17
+ const stubFilename = path.basename(entryPath, isMaybeCjs ? ext : undefined) + '-stub.mjs';
18
18
  const stubRelativePath = path.dirname(entryPath);
19
19
  const stubFolderPath = path.resolve(inputPath, './node_modules/.cache/cloudpack-stubs/', stubRelativePath);
20
20
  await mkdir(stubFolderPath, { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"getStubPath.js","sourceRoot":"","sources":["../src/getStubPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAKjC;IACC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAClD,MAAM,UAAU,GACd,QAAQ;QACR,CAAC,sBAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;IACnH,MAAM,WAAW,GAAG,GAAG,KAAK,OAAO,CAAC;IAEpC,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;QACpH,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wCAAwC,EAAE,gBAAgB,CAAC,CAAC;QAE3G,MAAM,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEjD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import path from 'path';\nimport { mkdir } from 'fs/promises';\nimport { detectModuleType } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\nexport const supportedCJSExtensions = ['.js', '.cjs'];\n\n/**\n * Given an (absolute) inputPath and (relative) entryPath, returns an absolute stub path\n * if a stub should indeed be generated for the entry. Otherwise returns undefined.\n */\nexport async function getStubPath(options: {\n inputPath: string;\n entryPath: string;\n /** Assume the entry is CJS (for testing only) */\n forceCJS?: boolean;\n}): Promise<string | undefined> {\n const { inputPath, entryPath, forceCJS } = options;\n\n const ext = path.extname(entryPath).toLowerCase();\n const isCJSEntry =\n forceCJS ||\n (supportedCJSExtensions.includes(ext) && (await detectModuleType(path.resolve(inputPath, entryPath))) === 'cjs');\n const isJSONEntry = ext === '.json';\n\n if (isCJSEntry || isJSONEntry) {\n const stubFilename = path.basename(entryPath, supportedCJSExtensions.includes(ext) ? ext : undefined) + '-stub.mjs';\n const stubRelativePath = path.dirname(entryPath);\n const stubFolderPath = path.resolve(inputPath, './node_modules/.cache/cloudpack-stubs/', stubRelativePath);\n\n await mkdir(stubFolderPath, { recursive: true });\n\n return slash(path.join(stubFolderPath, stubFilename));\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"getStubPath.js","sourceRoot":"","sources":["../src/getStubPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAG5F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAwE;IAExE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,sBAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAExD,IACE,wBAAwB,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtC,sEAAsE;QACtE,CAAC,UAAU,IAAI,CAAC,MAAM,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,EACtF,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;QAC1F,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wCAAwC,EAAE,gBAAgB,CAAC,CAAC;QAE3G,MAAM,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEjD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import path from 'path';\nimport { mkdir } from 'fs/promises';\nimport { detectModuleType } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { supportedCjsExtensions, supportedOtherExtensions } from './supportedExtensions.js';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\n\n/**\n * Given an (absolute) inputPath and (relative) entryPath, returns an absolute stub path\n * if a stub should indeed be generated for the entry. Otherwise returns undefined.\n */\nexport async function getStubPath(\n options: Pick<WriteESMStubsOptions, 'inputPath'> & { entryPath: string },\n): Promise<string | undefined> {\n const { inputPath, entryPath } = options;\n\n const ext = path.extname(entryPath).toLowerCase();\n const isMaybeCjs = supportedCjsExtensions.includes(ext);\n\n if (\n supportedOtherExtensions.includes(ext) ||\n // detectModuleType will only parse the module if it's .js (ambiguous)\n (isMaybeCjs && (await detectModuleType(path.resolve(inputPath, entryPath))) === 'cjs')\n ) {\n const stubFilename = path.basename(entryPath, isMaybeCjs ? ext : undefined) + '-stub.mjs';\n const stubRelativePath = path.dirname(entryPath);\n const stubFolderPath = path.resolve(inputPath, './node_modules/.cache/cloudpack-stubs/', stubRelativePath);\n\n await mkdir(stubFolderPath, { recursive: true });\n\n return slash(path.join(stubFolderPath, stubFilename));\n }\n\n return undefined;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /** CJS or maybe-CJS extensions supported for stubbing (js, cjs) */
2
+ export declare const supportedCjsExtensions: string[];
3
+ /** Other supported extensions for stubbing (json) */
4
+ export declare const supportedOtherExtensions: string[];
5
+ /** All extensions potentially supported for stubbing (js, cjs, json) */
6
+ export declare const supportedExtensions: string[];
7
+ //# sourceMappingURL=supportedExtensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supportedExtensions.d.ts","sourceRoot":"","sources":["../src/supportedExtensions.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,UAAkB,CAAC;AAEtD,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,UAAY,CAAC;AAElD,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,UAA2D,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** CJS or maybe-CJS extensions supported for stubbing (js, cjs) */
2
+ export const supportedCjsExtensions = ['.js', '.cjs'];
3
+ /** Other supported extensions for stubbing (json) */
4
+ export const supportedOtherExtensions = ['.json'];
5
+ /** All extensions potentially supported for stubbing (js, cjs, json) */
6
+ export const supportedExtensions = [...supportedCjsExtensions, ...supportedOtherExtensions];
7
+ //# sourceMappingURL=supportedExtensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supportedExtensions.js","sourceRoot":"","sources":["../src/supportedExtensions.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtD,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAO,CAAC,CAAC;AAElD,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,sBAAsB,EAAE,GAAG,wBAAwB,CAAC,CAAC","sourcesContent":["/** CJS or maybe-CJS extensions supported for stubbing (js, cjs) */\nexport const supportedCjsExtensions = ['.js', '.cjs'];\n\n/** Other supported extensions for stubbing (json) */\nexport const supportedOtherExtensions = ['.json'];\n\n/** All extensions potentially supported for stubbing (js, cjs, json) */\nexport const supportedExtensions = [...supportedCjsExtensions, ...supportedOtherExtensions];\n"]}
@@ -1,6 +1,3 @@
1
1
  import type { BundleOptions } from '@ms-cloudpack/common-types';
2
- export type WriteESMStubsOptions = Pick<BundleOptions, 'inputPath' | 'entries'> & {
3
- /** Assume entries are CJS (for testing). */
4
- forceCJS?: boolean;
5
- };
2
+ export type WriteESMStubsOptions = Pick<BundleOptions, 'inputPath' | 'entries'>;
6
3
  //# sourceMappingURL=WriteESMStubsOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WriteESMStubsOptions.d.ts","sourceRoot":"","sources":["../../src/types/WriteESMStubsOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG;IAChF,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"WriteESMStubsOptions.d.ts","sourceRoot":"","sources":["../../src/types/WriteESMStubsOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WriteESMStubsOptions.js","sourceRoot":"","sources":["../../src/types/WriteESMStubsOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleOptions } from '@ms-cloudpack/common-types';\n\nexport type WriteESMStubsOptions = Pick<BundleOptions, 'inputPath' | 'entries'> & {\n /** Assume entries are CJS (for testing). */\n forceCJS?: boolean;\n};\n"]}
1
+ {"version":3,"file":"WriteESMStubsOptions.js","sourceRoot":"","sources":["../../src/types/WriteESMStubsOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleOptions } from '@ms-cloudpack/common-types';\n\nexport type WriteESMStubsOptions = Pick<BundleOptions, 'inputPath' | 'entries'>;\n"]}
@@ -10,7 +10,7 @@ import { processError } from './processError.js';
10
10
  * If any files doesn't need a stub, the returned entry will use the original path.
11
11
  */
12
12
  export async function writeESMStubs(options) {
13
- const { inputPath, entries, forceCJS } = options;
13
+ const { inputPath, entries } = options;
14
14
  const result = {
15
15
  newEntries: {},
16
16
  errors: [],
@@ -19,7 +19,7 @@ export async function writeESMStubs(options) {
19
19
  const filePath = slash(path.join(inputPath, entryPath));
20
20
  const entryFullPath = path.join(inputPath, entryPath);
21
21
  try {
22
- const stubPath = await getStubPath({ inputPath, entryPath, forceCJS });
22
+ const stubPath = await getStubPath({ inputPath, entryPath });
23
23
  if (!stubPath) {
24
24
  // Stub not needed
25
25
  result.newEntries[entryKey] = entryFullPath;
@@ -1 +1 @@
1
- {"version":3,"file":"writeESMStubs.js","sourceRoot":"","sources":["../src/writeESMStubs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,MAAM,GAAwB;QAClC,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;YACvE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,kBAAkB;gBAClB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;gBAC5C,SAAS;YACX,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,2BAA2B,QAAQ,OAAO,QAAQ,EAAE,CAAC,CAAC;YAEpE,IAAI,WAAW,GAAW,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;gBACtD,WAAW,GAAG,MAAM,uBAAuB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACN,WAAW,GAAG,sBAAsB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC/D,CAAC;YAED,+BAA+B;YAC/B,MAAM,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAEhD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { slash } from '@ms-cloudpack/path-string-parsing';\nimport { writeFile } from 'fs/promises';\nimport path from 'path';\nimport { generateESMStubFromCJS } from './generateESMStubFromCJS.js';\nimport { generateESMStubFromJSON } from './generateESMStubFromJSON.js';\nimport { getStubPath } from './getStubPath.js';\nimport { processError } from './processError.js';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\nimport type { WriteESMStubsResult } from './types/WriteESMStubsResult.js';\n\n/**\n * Generates a set of ESM stubs for given entries and writes it to disk.\n * If any files doesn't need a stub, the returned entry will use the original path.\n */\nexport async function writeESMStubs(options: WriteESMStubsOptions): Promise<WriteESMStubsResult> {\n const { inputPath, entries, forceCJS } = options;\n const result: WriteESMStubsResult = {\n newEntries: {},\n errors: [],\n };\n\n for (const [entryKey, entryPath] of Object.entries(entries)) {\n const filePath = slash(path.join(inputPath, entryPath));\n const entryFullPath = path.join(inputPath, entryPath);\n\n try {\n const stubPath = await getStubPath({ inputPath, entryPath, forceCJS });\n if (!stubPath) {\n // Stub not needed\n result.newEntries[entryKey] = entryFullPath;\n continue;\n }\n\n console.debug(`Generating ESM stub for ${filePath} at ${stubPath}`);\n\n let stubContent: string = '';\n if (path.extname(entryPath).toLowerCase() === '.json') {\n stubContent = await generateESMStubFromJSON({ filePath });\n } else {\n stubContent = generateESMStubFromCJS({ filePath, stubPath });\n }\n\n // Attempt to write it to disk.\n await writeFile(stubPath, stubContent, 'utf-8');\n\n result.newEntries[entryKey] = stubPath;\n } catch (e) {\n result.newEntries[entryKey] = entryFullPath;\n result.errors.push(processError({ entryKey, entryFullPath, inputPath, error: e }));\n }\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"writeESMStubs.js","sourceRoot":"","sources":["../src/writeESMStubs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,MAAM,GAAwB;QAClC,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7D,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,kBAAkB;gBAClB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;gBAC5C,SAAS;YACX,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,2BAA2B,QAAQ,OAAO,QAAQ,EAAE,CAAC,CAAC;YAEpE,IAAI,WAAW,GAAW,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;gBACtD,WAAW,GAAG,MAAM,uBAAuB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACN,WAAW,GAAG,sBAAsB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC/D,CAAC;YAED,+BAA+B;YAC/B,MAAM,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAEhD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { slash } from '@ms-cloudpack/path-string-parsing';\nimport { writeFile } from 'fs/promises';\nimport path from 'path';\nimport { generateESMStubFromCJS } from './generateESMStubFromCJS.js';\nimport { generateESMStubFromJSON } from './generateESMStubFromJSON.js';\nimport { getStubPath } from './getStubPath.js';\nimport { processError } from './processError.js';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\nimport type { WriteESMStubsResult } from './types/WriteESMStubsResult.js';\n\n/**\n * Generates a set of ESM stubs for given entries and writes it to disk.\n * If any files doesn't need a stub, the returned entry will use the original path.\n */\nexport async function writeESMStubs(options: WriteESMStubsOptions): Promise<WriteESMStubsResult> {\n const { inputPath, entries } = options;\n const result: WriteESMStubsResult = {\n newEntries: {},\n errors: [],\n };\n\n for (const [entryKey, entryPath] of Object.entries(entries)) {\n const filePath = slash(path.join(inputPath, entryPath));\n const entryFullPath = path.join(inputPath, entryPath);\n\n try {\n const stubPath = await getStubPath({ inputPath, entryPath });\n if (!stubPath) {\n // Stub not needed\n result.newEntries[entryKey] = entryFullPath;\n continue;\n }\n\n console.debug(`Generating ESM stub for ${filePath} at ${stubPath}`);\n\n let stubContent: string = '';\n if (path.extname(entryPath).toLowerCase() === '.json') {\n stubContent = await generateESMStubFromJSON({ filePath });\n } else {\n stubContent = generateESMStubFromCJS({ filePath, stubPath });\n }\n\n // Attempt to write it to disk.\n await writeFile(stubPath, stubContent, 'utf-8');\n\n result.newEntries[entryKey] = stubPath;\n } catch (e) {\n result.newEntries[entryKey] = entryFullPath;\n result.errors.push(processError({ entryKey, entryFullPath, inputPath, error: e }));\n }\n }\n\n return result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"writeESMStubsInWorker.d.ts","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAI1E;;GAEG;AAGH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,mBAAmB,CAAC,CA6C9B;AAED,wBAAsB,qBAAqB,kBAG1C"}
1
+ {"version":3,"file":"writeESMStubsInWorker.d.ts","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAM1E;;GAEG;AAGH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,mBAAmB,CAAC,CAuE9B;AAED,wBAAsB,qBAAqB,kBAG1C"}
@@ -1,5 +1,7 @@
1
1
  import { getAdjustedTimeout } from '@ms-cloudpack/environment';
2
2
  import { WorkerPool } from '@ms-cloudpack/worker-pool';
3
+ import { supportedExtensions } from './supportedExtensions.js';
4
+ import path from 'path';
3
5
  let workerPool;
4
6
  /**
5
7
  * Write ESM stubs using a worker pool.
@@ -7,13 +9,26 @@ let workerPool;
7
9
  // This is tested in bundler-rollup/src/writeESMStubsInWorker.test.ts so we can
8
10
  // use the compiled version of the workerEntry file.
9
11
  export async function writeESMStubsInWorker(options) {
10
- // Trim the options to only the necessary ones for the worker to reduce what's serialized
11
- // (a larger BundleOptions object was likely passed in)
12
- const onlyStubOptions = {
13
- inputPath: options.inputPath,
14
- entries: options.entries,
15
- forceCJS: options.forceCJS,
16
- };
12
+ const { inputPath, entries } = options;
13
+ // Mapping from entry key to entry absolute path
14
+ const nonStubbedEntries = {};
15
+ // We don't want to call into the worker for packages where stubbing is clearly not needed,
16
+ // such as packages with only TS entries. So filter the entries by whether they potentially
17
+ // need to be stubbed.
18
+ const entriesToMaybeStub = {};
19
+ for (const [entryKey, entryPath] of Object.entries(entries)) {
20
+ const ext = path.extname(entryPath).toLowerCase();
21
+ if (supportedExtensions.includes(ext)) {
22
+ entriesToMaybeStub[entryKey] = entryPath;
23
+ }
24
+ else {
25
+ nonStubbedEntries[entryKey] = path.join(inputPath, entryPath);
26
+ }
27
+ }
28
+ if (!Object.keys(entriesToMaybeStub).length) {
29
+ // Return early if there's nothing to stub
30
+ return { newEntries: nonStubbedEntries, errors: [] };
31
+ }
17
32
  workerPool ??= new WorkerPool({
18
33
  name: 'ESM stub generation',
19
34
  parentPath: import.meta.url,
@@ -32,11 +47,18 @@ export async function writeESMStubsInWorker(options) {
32
47
  // console.warn if a stub takes longer than this
33
48
  warnAboveTime: getAdjustedTimeout(2000),
34
49
  });
50
+ const stubOptions = {
51
+ inputPath: options.inputPath,
52
+ entries: entriesToMaybeStub,
53
+ };
35
54
  try {
36
- return await workerPool.execute({
55
+ const stubResult = await workerPool.execute({
37
56
  method: 'writeESMStubs',
38
- args: [onlyStubOptions],
57
+ args: [stubOptions],
39
58
  });
59
+ // Add in any non-stubbed entries
60
+ Object.assign(stubResult.newEntries, nonStubbedEntries);
61
+ return stubResult;
40
62
  }
41
63
  catch (err) {
42
64
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"writeESMStubsInWorker.js","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,IAAI,UAAkC,CAAC;AAEvC;;GAEG;AACH,+EAA+E;AAC/E,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAuD;IAEvD,yFAAyF;IACzF,uDAAuD;IACvD,MAAM,eAAe,GAAyB;QAC5C,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;IAEF,UAAU,KAAK,IAAI,UAAU,CAAC;QAC5B,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;QAC3B,SAAS,EAAE,sBAAsB;QACjC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;QACnC,2FAA2F;QAC3F,+FAA+F;QAC/F,6FAA6F;QAC7F,2FAA2F;QAC3F,4BAA4B;QAC5B,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;QAC9B,4FAA4F;QAC5F,oFAAoF;QACpF,iGAAiG;QACjG,WAAW,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;QAC9B,gDAAgD;QAChD,aAAa,EAAE,kBAAkB,CAAC,IAAI,CAAC;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,OAAO,CAAsB;YACnD,MAAM,EAAE,eAAe;YACvB,IAAI,EAAE,CAAC,eAAe,CAAC;SACxB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,UAAU,EAAE,EAAE;YACd,MAAM,EAAE;gBACN;oBACE,MAAM,EAAE,qBAAqB;oBAC7B,mEAAmE;oBACnE,IAAI,EAAG,GAAa,EAAE,KAAK,IAAK,GAAa,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;iBACtE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,UAAU,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC","sourcesContent":["import { getAdjustedTimeout } from '@ms-cloudpack/environment';\nimport { WorkerPool } from '@ms-cloudpack/worker-pool';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\nimport type { WriteESMStubsResult } from './types/WriteESMStubsResult.js';\n\nlet workerPool: WorkerPool | undefined;\n\n/**\n * Write ESM stubs using a worker pool.\n */\n// This is tested in bundler-rollup/src/writeESMStubsInWorker.test.ts so we can\n// use the compiled version of the workerEntry file.\nexport async function writeESMStubsInWorker(\n options: WriteESMStubsOptions & { maxWorkers?: number },\n): Promise<WriteESMStubsResult> {\n // Trim the options to only the necessary ones for the worker to reduce what's serialized\n // (a larger BundleOptions object was likely passed in)\n const onlyStubOptions: WriteESMStubsOptions = {\n inputPath: options.inputPath,\n entries: options.entries,\n forceCJS: options.forceCJS,\n };\n\n workerPool ??= new WorkerPool({\n name: 'ESM stub generation',\n parentPath: import.meta.url,\n entryPath: './worker/workerEntry',\n maxWorkers: options.maxWorkers || 5,\n // Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of\n // OOM crashes if cloudpack start is left running for a long time (though it's much more likely\n // that the issue is caused by servers or file watchers). The timeout is conservative because\n // the fake browser environment has nontrivial startup time, so killing workers too quickly\n // could slow down rebuilds.\n inactiveTimeout: 5 * 60 * 1000,\n // Most stubs seem to stay well under this size, and Node appears to be decent about freeing\n // memory after writeESMStubs finishes, but this will catch anything giant or leaky.\n // (This is only checked after task completion, so a package exceeding it will still be stubbed.)\n maxHeapSize: 500 * 1024 * 1024,\n // console.warn if a stub takes longer than this\n warnAboveTime: getAdjustedTimeout(2000),\n });\n\n try {\n return await workerPool.execute<WriteESMStubsResult>({\n method: 'writeESMStubs',\n args: [onlyStubOptions],\n });\n } catch (err) {\n return {\n newEntries: {},\n errors: [\n {\n source: 'ESM stub generation',\n // note: err won't be an instance of Error because of serialization\n text: (err as Error)?.stack || (err as Error)?.message || String(err),\n },\n ],\n };\n }\n}\n\nexport async function disposeStubWorkerPool() {\n await workerPool?.dispose();\n workerPool = undefined;\n}\n"]}
1
+ {"version":3,"file":"writeESMStubsInWorker.js","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"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","sourcesContent":["import { getAdjustedTimeout } from '@ms-cloudpack/environment';\nimport { WorkerPool } from '@ms-cloudpack/worker-pool';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\nimport type { WriteESMStubsResult } from './types/WriteESMStubsResult.js';\nimport { supportedExtensions } from './supportedExtensions.js';\nimport path from 'path';\n\nlet workerPool: WorkerPool | undefined;\n\n/**\n * Write ESM stubs using a worker pool.\n */\n// This is tested in bundler-rollup/src/writeESMStubsInWorker.test.ts so we can\n// use the compiled version of the workerEntry file.\nexport async function writeESMStubsInWorker(\n options: WriteESMStubsOptions & { maxWorkers?: number },\n): Promise<WriteESMStubsResult> {\n const { inputPath, entries } = options;\n\n // Mapping from entry key to entry absolute path\n const nonStubbedEntries: WriteESMStubsResult['newEntries'] = {};\n\n // We don't want to call into the worker for packages where stubbing is clearly not needed,\n // such as packages with only TS entries. So filter the entries by whether they potentially\n // need to be stubbed.\n const entriesToMaybeStub: Record<string, string> = {};\n\n for (const [entryKey, entryPath] of Object.entries(entries)) {\n const ext = path.extname(entryPath).toLowerCase();\n if (supportedExtensions.includes(ext)) {\n entriesToMaybeStub[entryKey] = entryPath;\n } else {\n nonStubbedEntries[entryKey] = path.join(inputPath, entryPath);\n }\n }\n\n if (!Object.keys(entriesToMaybeStub).length) {\n // Return early if there's nothing to stub\n return { newEntries: nonStubbedEntries, errors: [] };\n }\n\n workerPool ??= new WorkerPool({\n name: 'ESM stub generation',\n parentPath: import.meta.url,\n entryPath: './worker/workerEntry',\n maxWorkers: options.maxWorkers || 5,\n // Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of\n // OOM crashes if cloudpack start is left running for a long time (though it's much more likely\n // that the issue is caused by servers or file watchers). The timeout is conservative because\n // the fake browser environment has nontrivial startup time, so killing workers too quickly\n // could slow down rebuilds.\n inactiveTimeout: 5 * 60 * 1000,\n // Most stubs seem to stay well under this size, and Node appears to be decent about freeing\n // memory after writeESMStubs finishes, but this will catch anything giant or leaky.\n // (This is only checked after task completion, so a package exceeding it will still be stubbed.)\n maxHeapSize: 500 * 1024 * 1024,\n // console.warn if a stub takes longer than this\n warnAboveTime: getAdjustedTimeout(2000),\n });\n\n const stubOptions: WriteESMStubsOptions = {\n inputPath: options.inputPath,\n entries: entriesToMaybeStub,\n };\n\n try {\n const stubResult = await workerPool.execute<WriteESMStubsResult>({\n method: 'writeESMStubs',\n args: [stubOptions],\n });\n\n // Add in any non-stubbed entries\n Object.assign(stubResult.newEntries, nonStubbedEntries);\n\n return stubResult;\n } catch (err) {\n return {\n newEntries: {},\n errors: [\n {\n source: 'ESM stub generation',\n // note: err won't be an instance of Error because of serialization\n text: (err as Error)?.stack || (err as Error)?.message || String(err),\n },\n ],\n };\n }\n}\n\nexport async function disposeStubWorkerPool() {\n await workerPool?.dispose();\n workerPool = undefined;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/esm-stub-utilities",
3
- "version": "0.13.21",
3
+ "version": "0.13.22",
4
4
  "description": "Generates ESM stubs for CommonJS entry files.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "@ms-cloudpack/json-utilities": "^0.1.9",
20
20
  "@ms-cloudpack/package-utilities": "^11.0.0",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
22
- "@ms-cloudpack/worker-pool": "^0.3.1",
22
+ "@ms-cloudpack/worker-pool": "^0.3.2",
23
23
  "jsdom": "^24.0.0",
24
24
  "jsdom-global": "^3.0.2",
25
25
  "regenerator-runtime": "^0.14.1"