@ms-cloudpack/bundler-utilities 0.4.3 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"getCssRule.d.ts","sourceRoot":"","sources":["../src/getCssRule.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG;IACpD,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QAEb,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,CAAC,CAAC;KACvE,CAAC,CAAC;CACJ,CA4CA"}
1
+ {"version":3,"file":"getCssRule.d.ts","sourceRoot":"","sources":["../src/getCssRule.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG;IACpD,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QAEb,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,CAAC,CAAC;KACvE,CAAC,CAAC;CACJ,CA2CA"}
package/lib/getCssRule.js CHANGED
@@ -14,20 +14,20 @@ export function getCssRule(fileType) {
14
14
  {
15
15
  loader: 'css-loader',
16
16
  options: {
17
- modules: type === 'plain'
18
- ? // TODO: determine whether we want CSS modules parsing/exports for plain CSS
19
- // (we didn't enable it in webpack previously)
20
- undefined
21
- : {
22
- mode: type === 'module' ? 'local' : 'global',
23
- localIdentName: '[local]__[hash:base64]',
24
- // TODO: once upgraded to css-loader v7 with some bug fixes, investigate
25
- // enabling this (previously we used v6's default value of false)
26
- namedExport: false,
27
- // Consider this too:
28
- // // Include global classes/IDs in exports
29
- // exportGlobals: true,
30
- },
17
+ modules: {
18
+ mode: type === 'module' ? 'local' : 'global',
19
+ // this could be changed for production bundling if needed
20
+ localIdentName: '[local]__[hash:base64]',
21
+ // Include global classes/IDs in exports
22
+ exportGlobals: true,
23
+ // Use original class names as keys in the default export, even if they're
24
+ // not valid identifiers
25
+ exportLocalsConvention: 'as-is',
26
+ // Unfortunately, css-loader explicitly refuses to support both named exports
27
+ // and a default object... https://github.com/webpack-contrib/css-loader/issues/1184
28
+ // For now prefer the default export, but we can re-evaluate if needed.
29
+ namedExport: false,
30
+ },
31
31
  },
32
32
  },
33
33
  ...(fileType === 'sass'
@@ -1 +1 @@
1
- {"version":3,"file":"getCssRule.js","sourceRoot":"","sources":["../src/getCssRule.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAwB;IAOjD,OAAO;QACL,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClD,qFAAqF;YACrF,IAAI,EAAE,IAAI,MAAM,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG,CAAC;YAC9G,6FAA6F;YAC7F,yFAAyF;YACzF,kFAAkF;YAClF,GAAG,EAAE;gBACH,cAAc;gBACd;oBACE,MAAM,EAAE,YAAY;oBACpB,OAAO,EAAE;wBACP,OAAO,EACL,IAAI,KAAK,OAAO;4BACd,CAAC,CAAC,4EAA4E;gCAC5E,8CAA8C;gCAC9C,SAAS;4BACX,CAAC,CAAC;gCACE,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;gCAC5C,cAAc,EAAE,wBAAwB;gCACxC,wEAAwE;gCACxE,iEAAiE;gCACjE,WAAW,EAAE,KAAK;gCAClB,qBAAqB;gCACrB,2CAA2C;gCAC3C,uBAAuB;6BACxB;qBACR;iBACF;gBACD,GAAG,CAAC,QAAQ,KAAK,MAAM;oBACrB,CAAC,CAAC;wBACE;4BACE,MAAM,EAAE,aAAa;4BACrB,OAAO,EAAE;gCACP,iCAAiC;gCACjC,WAAW,EAAE,EAAE,mBAAmB,EAAE,CAAC,eAAe,CAAC,EAAE;6BACxD;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Get a webpack/rspack `RuleSetRule` for handling css/sass files.\n */\nexport function getCssRule(fileType: 'css' | 'sass'): {\n oneOf: Array<{\n test: RegExp;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matching webpack RuleSetRule\n use: Array<string | { loader: string; options: Record<string, any> }>;\n }>;\n} {\n return {\n oneOf: ['global', 'module', 'plain'].map((type) => ({\n // These are used within oneOf (pick first matching rule), so we don't need `exclude`\n test: new RegExp(`${type === 'plain' ? '' : `\\\\.${type}`}\\\\.${fileType === 'sass' ? 's[ac]ss' : 'css'}$`, 'i'),\n // With webpack/rspack, it's possible to set sideEffects: true to force all CSS imports to be\n // treated as having side effects regardless of sideEffects in package.json. However, ori\n // doesn't seem to have an equivalent setting, so we skip it here for consistency.\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules:\n type === 'plain'\n ? // TODO: determine whether we want CSS modules parsing/exports for plain CSS\n // (we didn't enable it in webpack previously)\n undefined\n : {\n mode: type === 'module' ? 'local' : 'global',\n localIdentName: '[local]__[hash:base64]',\n // TODO: once upgraded to css-loader v7 with some bug fixes, investigate\n // enabling this (previously we used v6's default value of false)\n namedExport: false,\n // Consider this too:\n // // Include global classes/IDs in exports\n // exportGlobals: true,\n },\n },\n },\n ...(fileType === 'sass'\n ? [\n {\n loader: 'sass-loader',\n options: {\n // spammy, non-actionable warning\n sassOptions: { silenceDeprecations: ['legacy-js-api'] },\n },\n },\n ]\n : []),\n ],\n })),\n };\n}\n"]}
1
+ {"version":3,"file":"getCssRule.js","sourceRoot":"","sources":["../src/getCssRule.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAwB;IAOjD,OAAO;QACL,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClD,qFAAqF;YACrF,IAAI,EAAE,IAAI,MAAM,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG,CAAC;YAC9G,6FAA6F;YAC7F,yFAAyF;YACzF,kFAAkF;YAClF,GAAG,EAAE;gBACH,cAAc;gBACd;oBACE,MAAM,EAAE,YAAY;oBACpB,OAAO,EAAE;wBACP,OAAO,EAAE;4BACP,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;4BAC5C,0DAA0D;4BAC1D,cAAc,EAAE,wBAAwB;4BACxC,wCAAwC;4BACxC,aAAa,EAAE,IAAI;4BACnB,0EAA0E;4BAC1E,wBAAwB;4BACxB,sBAAsB,EAAE,OAAO;4BAC/B,6EAA6E;4BAC7E,oFAAoF;4BACpF,uEAAuE;4BACvE,WAAW,EAAE,KAAK;yBACnB;qBACF;iBACF;gBACD,GAAG,CAAC,QAAQ,KAAK,MAAM;oBACrB,CAAC,CAAC;wBACE;4BACE,MAAM,EAAE,aAAa;4BACrB,OAAO,EAAE;gCACP,iCAAiC;gCACjC,WAAW,EAAE,EAAE,mBAAmB,EAAE,CAAC,eAAe,CAAC,EAAE;6BACxD;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Get a webpack/rspack `RuleSetRule` for handling css/sass files.\n */\nexport function getCssRule(fileType: 'css' | 'sass'): {\n oneOf: Array<{\n test: RegExp;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matching webpack RuleSetRule\n use: Array<string | { loader: string; options: Record<string, any> }>;\n }>;\n} {\n return {\n oneOf: ['global', 'module', 'plain'].map((type) => ({\n // These are used within oneOf (pick first matching rule), so we don't need `exclude`\n test: new RegExp(`${type === 'plain' ? '' : `\\\\.${type}`}\\\\.${fileType === 'sass' ? 's[ac]ss' : 'css'}$`, 'i'),\n // With webpack/rspack, it's possible to set sideEffects: true to force all CSS imports to be\n // treated as having side effects regardless of sideEffects in package.json. However, ori\n // doesn't seem to have an equivalent setting, so we skip it here for consistency.\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules: {\n mode: type === 'module' ? 'local' : 'global',\n // this could be changed for production bundling if needed\n localIdentName: '[local]__[hash:base64]',\n // Include global classes/IDs in exports\n exportGlobals: true,\n // Use original class names as keys in the default export, even if they're\n // not valid identifiers\n exportLocalsConvention: 'as-is',\n // Unfortunately, css-loader explicitly refuses to support both named exports\n // and a default object... https://github.com/webpack-contrib/css-loader/issues/1184\n // For now prefer the default export, but we can re-evaluate if needed.\n namedExport: false,\n },\n },\n },\n ...(fileType === 'sass'\n ? [\n {\n loader: 'sass-loader',\n options: {\n // spammy, non-actionable warning\n sassOptions: { silenceDeprecations: ['legacy-js-api'] },\n },\n },\n ]\n : []),\n ],\n })),\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Resolve the given modules relative to the calling package, and return a list of unique
3
- * containing folders (usually `node_modules` folders) which webpack/rspack can use as module
4
- * search paths in `config.resolveLoader.modules`.
3
+ * containing `node_modules` folders which webpack/rspack can use as module search paths in
4
+ * `config.resolveLoader.modules`. (Results are cached per `import.meta.url`.)
5
5
  * @param modules - The modules to resolve. Must be dependencies of this package.
6
6
  * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.
7
7
  * @returns Containing folders of the modules. (ie: `/path/to/node_modules/`)
@@ -1 +1 @@
1
- {"version":3,"file":"getModuleSearchPaths.d.ts","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,wBAAwB,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBlG"}
1
+ {"version":3,"file":"getModuleSearchPaths.d.ts","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,wBAAwB,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBlG"}
@@ -1,15 +1,20 @@
1
1
  import { findPackageRoot, resolveModule } from '@ms-cloudpack/path-utilities';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ /** Mapping from `resolveFromImportMetaUrl` to paths */
5
+ const cachedSearchPaths = {};
4
6
  /**
5
7
  * Resolve the given modules relative to the calling package, and return a list of unique
6
- * containing folders (usually `node_modules` folders) which webpack/rspack can use as module
7
- * search paths in `config.resolveLoader.modules`.
8
+ * containing `node_modules` folders which webpack/rspack can use as module search paths in
9
+ * `config.resolveLoader.modules`. (Results are cached per `import.meta.url`.)
8
10
  * @param modules - The modules to resolve. Must be dependencies of this package.
9
11
  * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.
10
12
  * @returns Containing folders of the modules. (ie: `/path/to/node_modules/`)
11
13
  */
12
14
  export function getModuleSearchPaths(modules, resolveFromImportMetaUrl) {
15
+ if (cachedSearchPaths[resolveFromImportMetaUrl]) {
16
+ return cachedSearchPaths[resolveFromImportMetaUrl];
17
+ }
13
18
  const paths = new Set();
14
19
  for (const moduleName of modules) {
15
20
  // Resolve the module path and find the package root from there.
@@ -21,9 +26,11 @@ export function getModuleSearchPaths(modules, resolveFromImportMetaUrl) {
21
26
  });
22
27
  const packageRoot = findPackageRoot(fileURLToPath(moduleUrl));
23
28
  if (packageRoot) {
29
+ // Walk up to the node_modules folder above the package root
24
30
  paths.add(path.dirname(packageRoot));
25
31
  }
26
32
  }
27
- return Array.from(paths);
33
+ cachedSearchPaths[resolveFromImportMetaUrl] = Array.from(paths);
34
+ return cachedSearchPaths[resolveFromImportMetaUrl];
28
35
  }
29
36
  //# sourceMappingURL=getModuleSearchPaths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getModuleSearchPaths.js","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAiB,EAAE,wBAAgC;IACtF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,gEAAgE;QAChE,qGAAqG;QACrG,MAAM,SAAS,GAAG,aAAa,CAAC;YAC9B,eAAe,EAAE,UAAU;YAC3B,SAAS,EAAE,wBAAwB;YACnC,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,eAAe,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9D,IAAI,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { findPackageRoot, resolveModule } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\n/**\n * Resolve the given modules relative to the calling package, and return a list of unique\n * containing folders (usually `node_modules` folders) which webpack/rspack can use as module\n * search paths in `config.resolveLoader.modules`.\n * @param modules - The modules to resolve. Must be dependencies of this package.\n * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.\n * @returns Containing folders of the modules. (ie: `/path/to/node_modules/`)\n */\nexport function getModuleSearchPaths(modules: string[], resolveFromImportMetaUrl: string): string[] {\n const paths = new Set<string>();\n\n for (const moduleName of modules) {\n // Resolve the module path and find the package root from there.\n // preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store.\n const moduleUrl = resolveModule({\n importSpecifier: moduleName,\n parentUrl: resolveFromImportMetaUrl,\n preserveSymlinks: true,\n });\n const packageRoot = findPackageRoot(fileURLToPath(moduleUrl));\n if (packageRoot) {\n paths.add(path.dirname(packageRoot));\n }\n }\n\n return Array.from(paths);\n}\n"]}
1
+ {"version":3,"file":"getModuleSearchPaths.js","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,uDAAuD;AACvD,MAAM,iBAAiB,GAA6B,EAAE,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAiB,EAAE,wBAAgC;IACtF,IAAI,iBAAiB,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAChD,OAAO,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,gEAAgE;QAChE,qGAAqG;QACrG,MAAM,SAAS,GAAG,aAAa,CAAC;YAC9B,eAAe,EAAE,UAAU;YAC3B,SAAS,EAAE,wBAAwB;YACnC,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,eAAe,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9D,IAAI,WAAW,EAAE,CAAC;YAChB,4DAA4D;YAC5D,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,iBAAiB,CAAC,wBAAwB,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { findPackageRoot, resolveModule } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\n/** Mapping from `resolveFromImportMetaUrl` to paths */\nconst cachedSearchPaths: Record<string, string[]> = {};\n\n/**\n * Resolve the given modules relative to the calling package, and return a list of unique\n * containing `node_modules` folders which webpack/rspack can use as module search paths in\n * `config.resolveLoader.modules`. (Results are cached per `import.meta.url`.)\n * @param modules - The modules to resolve. Must be dependencies of this package.\n * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.\n * @returns Containing folders of the modules. (ie: `/path/to/node_modules/`)\n */\nexport function getModuleSearchPaths(modules: string[], resolveFromImportMetaUrl: string): string[] {\n if (cachedSearchPaths[resolveFromImportMetaUrl]) {\n return cachedSearchPaths[resolveFromImportMetaUrl];\n }\n\n const paths = new Set<string>();\n\n for (const moduleName of modules) {\n // Resolve the module path and find the package root from there.\n // preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store.\n const moduleUrl = resolveModule({\n importSpecifier: moduleName,\n parentUrl: resolveFromImportMetaUrl,\n preserveSymlinks: true,\n });\n const packageRoot = findPackageRoot(fileURLToPath(moduleUrl));\n if (packageRoot) {\n // Walk up to the node_modules folder above the package root\n paths.add(path.dirname(packageRoot));\n }\n }\n\n cachedSearchPaths[resolveFromImportMetaUrl] = Array.from(paths);\n return cachedSearchPaths[resolveFromImportMetaUrl];\n}\n"]}
@@ -8,22 +8,21 @@ interface GetSwcConfigParams {
8
8
  /**
9
9
  * Gets the SWC configuration for a package, either from `.swcrc`(`.json`), by converting
10
10
  * `tsconfig.json`, or using some basic default options.
11
+ * (Any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)
11
12
  *
12
13
  * Notably, this will use a higher default target level than the default SWC config to reduce
13
14
  * unnecessary downleveling, and override various options that are required for how cloudpack works.
14
15
  *
15
- * (Note that any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)
16
+ * (ori/esbuild has similar behavior of implicitly reading `tsconfig.json` and using that for
17
+ * certain transpilation settings.)
16
18
  *
17
- * @returns JS/TS(X) variants of the config, to avoid processing any config files twice.
18
- * (Properties are getters which do the appropriate merging on demand.)
19
+ * @returns JS/TS variants of the config, to avoid processing any config files twice.
19
20
  */
20
21
  export declare function getSwcConfig(params: GetSwcConfigParams): {
21
22
  /** Config for `.js` and `.jsx` files */
22
- get jsx(): SwcConfig;
23
- /** Config for `.ts` files (no TSX support) */
24
- get tsOnly(): SwcConfig;
25
- /** Config for `.tsx` files */
26
- get tsx(): SwcConfig;
23
+ jsx: SwcConfig;
24
+ /** Config for `.ts` and `.tsx` files */
25
+ tsx: SwcConfig;
27
26
  };
28
27
  export {};
29
28
  //# sourceMappingURL=getSwcConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSwcConfig.d.ts","sourceRoot":"","sources":["../src/getSwcConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,MAAM,IAAI,SAAS,EAAkB,MAAM,WAAW,CAAC;AAOrF,UAAU,kBAAkB;IAC1B,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAmBD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG;IACxD,wCAAwC;IAExC,IAAI,GAAG,IAAI,SAAS,CAAC;IACrB,8CAA8C;IAC9C,IAAI,MAAM,IAAI,SAAS,CAAC;IACxB,8BAA8B;IAC9B,IAAI,GAAG,IAAI,SAAS,CAAC;CACtB,CAiEA"}
1
+ {"version":3,"file":"getSwcConfig.d.ts","sourceRoot":"","sources":["../src/getSwcConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,MAAM,IAAI,SAAS,EAAkB,MAAM,WAAW,CAAC;AAOrF,UAAU,kBAAkB;IAC1B,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG;IACxD,wCAAwC;IACxC,GAAG,EAAE,SAAS,CAAC;IACf,wCAAwC;IACxC,GAAG,EAAE,SAAS,CAAC;CAChB,CA0DA"}
@@ -19,18 +19,18 @@ const getUniversalConfig = (params) => ({
19
19
  });
20
20
  const jsxParserConfig = { jsc: { parser: { syntax: 'ecmascript', jsx: true } } };
21
21
  const tsxParserConfig = { jsc: { parser: { syntax: 'typescript', tsx: true } } };
22
- const tsOnlyParserConfig = { jsc: { parser: { syntax: 'typescript', tsx: false } } };
23
22
  /**
24
23
  * Gets the SWC configuration for a package, either from `.swcrc`(`.json`), by converting
25
24
  * `tsconfig.json`, or using some basic default options.
25
+ * (Any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)
26
26
  *
27
27
  * Notably, this will use a higher default target level than the default SWC config to reduce
28
28
  * unnecessary downleveling, and override various options that are required for how cloudpack works.
29
29
  *
30
- * (Note that any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)
30
+ * (ori/esbuild has similar behavior of implicitly reading `tsconfig.json` and using that for
31
+ * certain transpilation settings.)
31
32
  *
32
- * @returns JS/TS(X) variants of the config, to avoid processing any config files twice.
33
- * (Properties are getters which do the appropriate merging on demand.)
33
+ * @returns JS/TS variants of the config, to avoid processing any config files twice.
34
34
  */
35
35
  export function getSwcConfig(params) {
36
36
  const { packagePath } = params;
@@ -79,15 +79,8 @@ export function getSwcConfig(params) {
79
79
  delete result.jsc?.parser?.tsx;
80
80
  delete result.jsc?.parser?.jsx;
81
81
  return {
82
- get jsx() {
83
- return mergeObjects([result, jsxParserConfig], { arrayMerge: 'overwrite' });
84
- },
85
- get tsx() {
86
- return mergeObjects([result, tsxParserConfig], { arrayMerge: 'overwrite' });
87
- },
88
- get tsOnly() {
89
- return mergeObjects([result, tsOnlyParserConfig], { arrayMerge: 'overwrite' });
90
- },
82
+ jsx: mergeObjects([result, jsxParserConfig], { arrayMerge: 'overwrite' }),
83
+ tsx: mergeObjects([result, tsxParserConfig], { arrayMerge: 'overwrite' }),
91
84
  };
92
85
  }
93
86
  //# sourceMappingURL=getSwcConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSwcConfig.js","sourceRoot":"","sources":["../src/getSwcConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AASrD,kCAAkC;AAClC,MAAM,kBAAkB,GAAG,CA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AAE,MAAyB,EAAE,GAAG,CAAC;IAEnD,OAAO;QACL,IAAI,GAAG;YACL,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,GAAG;YACL,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,MAAM;YACR,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QACjF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readJsonSync } from '@ms-cloudpack/json-utilities';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport type { EsParserConfig, Config as SwcConfig, TsParserConfig } from '@swc/core';\nimport fs from 'fs';\nimport { parseTsconfig } from 'get-tsconfig';\nimport path from 'path';\nimport { convertTsConfig } from 'tsconfig-to-swcconfig';\nimport { defaultTargetSyntax } from './constants.js';\n\ninterface GetSwcConfigParams {\n /** Absolute path to the package (`inputPath`) */\n packagePath: string;\n /** Whether to generate sourcemaps */\n sourcemap: boolean | undefined;\n}\n\n/** Overrides all other configs */\nconst getUniversalConfig = (params: Pick<GetSwcConfigParams, 'sourcemap'>): SwcConfig => ({\n jsc: {\n target: defaultTargetSyntax,\n // We can't reference the separate @swc/helpers package from bundles\n externalHelpers: false,\n },\n module: {\n type: 'es6',\n },\n sourceMaps: params.sourcemap,\n});\n\nconst jsxParserConfig: SwcConfig = { jsc: { parser: { syntax: 'ecmascript', jsx: true } } };\nconst tsxParserConfig: SwcConfig = { jsc: { parser: { syntax: 'typescript', tsx: true } } };\nconst tsOnlyParserConfig: SwcConfig = { jsc: { parser: { syntax: 'typescript', tsx: false } } };\n\n/**\n * Gets the SWC configuration for a package, either from `.swcrc`(`.json`), by converting\n * `tsconfig.json`, or using some basic default options.\n *\n * Notably, this will use a higher default target level than the default SWC config to reduce\n * unnecessary downleveling, and override various options that are required for how cloudpack works.\n *\n * (Note that any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)\n *\n * @returns JS/TS(X) variants of the config, to avoid processing any config files twice.\n * (Properties are getters which do the appropriate merging on demand.)\n */\nexport function getSwcConfig(params: GetSwcConfigParams): {\n /** Config for `.js` and `.jsx` files */\n // A JS-only variant could be added if needed\n get jsx(): SwcConfig;\n /** Config for `.ts` files (no TSX support) */\n get tsOnly(): SwcConfig;\n /** Config for `.tsx` files */\n get tsx(): SwcConfig;\n} {\n const { packagePath } = params;\n\n // First try reading .swcrc(.json).\n // (It might have comments but doesn't have config extension, at least in v1.)\n const swcrc: SwcConfig | SwcConfig[] | undefined =\n readJsonSync(path.join(packagePath, '.swcrc'), { mode: 'permissive' }) ||\n readJsonSync(path.join(packagePath, '.swcrc.json'), { mode: 'permissive' });\n\n let packageConfig: SwcConfig | undefined;\n // .swcrc can have either a single object or an array with `test`.\n // Possibly we could add some logic to handle the array based on file extensions\n // https://swc.rs/docs/configuration/compilation#multiple-entries\n if (Array.isArray(swcrc)) {\n console.warn(\n `Found array in .swcrc at ${packagePath} - this is not currently supported, so default settings will be used instead.`,\n );\n } else if (swcrc) {\n console.debug(`Found .swcrc at ${packagePath}`);\n packageConfig = swcrc;\n }\n\n const tsconfigPath = path.join(packagePath, 'tsconfig.json');\n if (!packageConfig && fs.existsSync(tsconfigPath)) {\n // Read tsconfig.json from the package path if present, and convert it to swc config.\n // (We use a separate read step instead of calling all-in-one tsconfig-to-swcconfig `convert()`\n // because that searches up parent dirs for a tsconfig.json, which is worse for perf.)\n try {\n const tsconfig = parseTsconfig(tsconfigPath);\n packageConfig = convertTsConfig(tsconfig.compilerOptions || {}, undefined, packagePath);\n } catch {\n // ignore\n }\n }\n\n const result = mergeObjects([packageConfig || {}, getUniversalConfig(params)], { arrayMerge: 'overwrite' });\n\n /**\n * Check if baseUrl is relative and convert it to absolute path\n * Swc doesn't support relative baseUrl paths\n */\n if (result.jsc && result.jsc?.baseUrl && !path.isAbsolute(result.jsc.baseUrl)) {\n result.jsc.baseUrl = path.join(packagePath, result.jsc.baseUrl);\n }\n\n // minifying should be up to the bundler\n delete result.jsc?.minify;\n // env conflicts with jsc.target -- currently we only use target\n // https://swc.rs/docs/configuration/compilation#env\n delete result.env;\n // delete jsx/tsx options (will apply the correct one in the last step)\n delete (result.jsc?.parser as TsParserConfig)?.tsx;\n delete (result.jsc?.parser as EsParserConfig)?.jsx;\n\n return {\n get jsx() {\n return mergeObjects([result, jsxParserConfig], { arrayMerge: 'overwrite' });\n },\n get tsx() {\n return mergeObjects([result, tsxParserConfig], { arrayMerge: 'overwrite' });\n },\n get tsOnly() {\n return mergeObjects([result, tsOnlyParserConfig], { arrayMerge: 'overwrite' });\n },\n };\n}\n"]}
1
+ {"version":3,"file":"getSwcConfig.js","sourceRoot":"","sources":["../src/getSwcConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AASrD,kCAAkC;AAClC,MAAM,kBAAkB,GAAG,CAAC,MAA6C,EAAa,EAAE,CAAC,CAAC;IACxF,GAAG,EAAE;QACH,MAAM,EAAE,mBAAmB;QAC3B,oEAAoE;QACpE,eAAe,EAAE,KAAK;KACvB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,KAAK;KACZ;IACD,UAAU,EAAE,MAAM,CAAC,SAAS;CAC7B,CAAC,CAAC;AAE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Aa,CAAC,YAAY,CAAC,CAAC;YAC7C,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QAC1F,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,aAAa,IAAI,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IAE5G;;;OAGG;IACH,IAAI,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9E,MAAM,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,wCAAwC;IACxC,OAAO,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,oDAAoD;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC;IAClB,uEAAuE;IACvE,OAAQ,MAAM,CAAC,GAAG,EAAE,MAAyB,EAAE,GAAG,CAAC;IACnD,OAAQ,MAAM,CAAC,GAAG,EAAE,MAAyB,EAAE,GAAG,CAAC;IAEnD,OAAO;QACL,GAAG,EAAE,YAAY,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QACzE,GAAG,EAAE,YAAY,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC","sourcesContent":["import { readJsonSync } from '@ms-cloudpack/json-utilities';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport type { EsParserConfig, Config as SwcConfig, TsParserConfig } from '@swc/core';\nimport fs from 'fs';\nimport { parseTsconfig } from 'get-tsconfig';\nimport path from 'path';\nimport { convertTsConfig } from 'tsconfig-to-swcconfig';\nimport { defaultTargetSyntax } from './constants.js';\n\ninterface GetSwcConfigParams {\n /** Absolute path to the package (`inputPath`) */\n packagePath: string;\n /** Whether to generate sourcemaps */\n sourcemap: boolean | undefined;\n}\n\n/** Overrides all other configs */\nconst getUniversalConfig = (params: Pick<GetSwcConfigParams, 'sourcemap'>): SwcConfig => ({\n jsc: {\n target: defaultTargetSyntax,\n // We can't reference the separate @swc/helpers package from bundles\n externalHelpers: false,\n },\n module: {\n type: 'es6',\n },\n sourceMaps: params.sourcemap,\n});\n\nconst jsxParserConfig: SwcConfig = { jsc: { parser: { syntax: 'ecmascript', jsx: true } } };\nconst tsxParserConfig: SwcConfig = { jsc: { parser: { syntax: 'typescript', tsx: true } } };\n\n/**\n * Gets the SWC configuration for a package, either from `.swcrc`(`.json`), by converting\n * `tsconfig.json`, or using some basic default options.\n * (Any unset options will use [swc defaults](https://swc.rs/docs/configuration/swcrc).)\n *\n * Notably, this will use a higher default target level than the default SWC config to reduce\n * unnecessary downleveling, and override various options that are required for how cloudpack works.\n *\n * (ori/esbuild has similar behavior of implicitly reading `tsconfig.json` and using that for\n * certain transpilation settings.)\n *\n * @returns JS/TS variants of the config, to avoid processing any config files twice.\n */\nexport function getSwcConfig(params: GetSwcConfigParams): {\n /** Config for `.js` and `.jsx` files */\n jsx: SwcConfig;\n /** Config for `.ts` and `.tsx` files */\n tsx: SwcConfig;\n} {\n const { packagePath } = params;\n\n // First try reading .swcrc(.json).\n // (It might have comments but doesn't have config extension, at least in v1.)\n const swcrc: SwcConfig | SwcConfig[] | undefined =\n readJsonSync(path.join(packagePath, '.swcrc'), { mode: 'permissive' }) ||\n readJsonSync(path.join(packagePath, '.swcrc.json'), { mode: 'permissive' });\n\n let packageConfig: SwcConfig | undefined;\n // .swcrc can have either a single object or an array with `test`.\n // Possibly we could add some logic to handle the array based on file extensions\n // https://swc.rs/docs/configuration/compilation#multiple-entries\n if (Array.isArray(swcrc)) {\n console.warn(\n `Found array in .swcrc at ${packagePath} - this is not currently supported, so default settings will be used instead.`,\n );\n } else if (swcrc) {\n console.debug(`Found .swcrc at ${packagePath}`);\n packageConfig = swcrc;\n }\n\n const tsconfigPath = path.join(packagePath, 'tsconfig.json');\n if (!packageConfig && fs.existsSync(tsconfigPath)) {\n // Read tsconfig.json from the package path if present, and convert it to swc config.\n // (We use a separate read step instead of calling all-in-one tsconfig-to-swcconfig `convert()`\n // because that searches up parent dirs for a tsconfig.json, which is worse for perf.)\n try {\n const tsconfig = parseTsconfig(tsconfigPath);\n packageConfig = convertTsConfig(tsconfig.compilerOptions || {}, undefined, packagePath);\n } catch {\n // ignore\n }\n }\n\n const result = mergeObjects([packageConfig || {}, getUniversalConfig(params)], { arrayMerge: 'overwrite' });\n\n /**\n * Check if baseUrl is relative and convert it to absolute path\n * Swc doesn't support relative baseUrl paths\n */\n if (result.jsc && result.jsc?.baseUrl && !path.isAbsolute(result.jsc.baseUrl)) {\n result.jsc.baseUrl = path.join(packagePath, result.jsc.baseUrl);\n }\n\n // minifying should be up to the bundler\n delete result.jsc?.minify;\n // env conflicts with jsc.target -- currently we only use target\n // https://swc.rs/docs/configuration/compilation#env\n delete result.env;\n // delete jsx/tsx options (will apply the correct one in the last step)\n delete (result.jsc?.parser as TsParserConfig)?.tsx;\n delete (result.jsc?.parser as EsParserConfig)?.jsx;\n\n return {\n jsx: mergeObjects([result, jsxParserConfig], { arrayMerge: 'overwrite' }),\n tsx: mergeObjects([result, tsxParserConfig], { arrayMerge: 'overwrite' }),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-utilities",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Utilities used by multiple bundlers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,14 +15,14 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@ms-cloudpack/json-utilities": "^0.1.10",
18
- "@ms-cloudpack/package-utilities": "^12.3.18",
18
+ "@ms-cloudpack/package-utilities": "^12.3.19",
19
19
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
20
- "@ms-cloudpack/path-utilities": "^3.1.12",
20
+ "@ms-cloudpack/path-utilities": "^3.1.13",
21
21
  "get-tsconfig": "^4.7.2",
22
22
  "tsconfig-to-swcconfig": "^2.7.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@ms-cloudpack/common-types": "^0.26.2",
25
+ "@ms-cloudpack/common-types": "^0.26.3",
26
26
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
27
27
  "@ms-cloudpack/scripts": "^0.0.1",
28
28
  "@ms-cloudpack/test-utilities": "^0.5.0",