@ms-cloudpack/bundler-utilities 0.9.3 → 0.9.7
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/lib/getSwcRelayPluginConfig.d.ts +13 -0
- package/lib/getSwcRelayPluginConfig.d.ts.map +1 -0
- package/lib/getSwcRelayPluginConfig.js +29 -0
- package/lib/getSwcRelayPluginConfig.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';
|
|
2
|
+
import type { ParserConfig, Config as SwcConfig } from '@swc/core';
|
|
3
|
+
/**
|
|
4
|
+
* Handle resolving and configuring the SWC Relay plugin.
|
|
5
|
+
* @returns A function that adds the SWC Relay plugin configuration to a given SWC config
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSwcRelayPluginConfig(params: {
|
|
8
|
+
/** Relay capability options (or `AppConfig.relay`) */
|
|
9
|
+
options: InternalBundlerCapabilitiesOptions['relay'];
|
|
10
|
+
/** `import.meta.url` of the calling module */
|
|
11
|
+
parentUrl: string;
|
|
12
|
+
}): (swcConfig: SwcConfig, syntax: ParserConfig['syntax']) => void;
|
|
13
|
+
//# sourceMappingURL=getSwcRelayPluginConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSwcRelayPluginConfig.d.ts","sourceRoot":"","sources":["../src/getSwcRelayPluginConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAEhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAInE;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,sDAAsD;IACtD,OAAO,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IACrD,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CA4BjE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { resolveModule } from '@ms-cloudpack/path-utilities';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
/**
|
|
4
|
+
* Handle resolving and configuring the SWC Relay plugin.
|
|
5
|
+
* @returns A function that adds the SWC Relay plugin configuration to a given SWC config
|
|
6
|
+
*/
|
|
7
|
+
export function getSwcRelayPluginConfig(params) {
|
|
8
|
+
const { options: opts, parentUrl } = params;
|
|
9
|
+
// Ensure options is always an object before spreading
|
|
10
|
+
const { rootDir, ...options } = (opts && typeof opts === 'object' ? opts : {});
|
|
11
|
+
if (!rootDir) {
|
|
12
|
+
throw new Error('The relay capability requires a rootDir option to be set.');
|
|
13
|
+
}
|
|
14
|
+
const relayPlugin = fileURLToPath(resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl }));
|
|
15
|
+
return (swcConfig, syntax) => {
|
|
16
|
+
const relayConfig = {
|
|
17
|
+
// This must be set or bundlers may default to "require" instead of inlining
|
|
18
|
+
eagerEsModules: true,
|
|
19
|
+
...options,
|
|
20
|
+
rootDir,
|
|
21
|
+
language: syntax === 'typescript' ? 'typescript' : 'javascript', // typo in plugin types
|
|
22
|
+
};
|
|
23
|
+
swcConfig.jsc ??= {};
|
|
24
|
+
swcConfig.jsc.experimental ??= {};
|
|
25
|
+
swcConfig.jsc.experimental.plugins ??= [];
|
|
26
|
+
swcConfig.jsc.experimental.plugins.push([relayPlugin, relayConfig]);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=getSwcRelayPluginConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSwcRelay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ourcesContent":["import type { AppConfig, InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport type { ParserConfig, Config as SwcConfig } from '@swc/core';\nimport type { Config as SwcRelayConfig } from '@swc/plugin-relay';\nimport { fileURLToPath } from 'url';\n\n/**\n * Handle resolving and configuring the SWC Relay plugin.\n * @returns A function that adds the SWC Relay plugin configuration to a given SWC config\n */\nexport function getSwcRelayPluginConfig(params: {\n /** Relay capability options (or `AppConfig.relay`) */\n options: InternalBundlerCapabilitiesOptions['relay'];\n /** `import.meta.url` of the calling module */\n parentUrl: string;\n}): (swcConfig: SwcConfig, syntax: ParserConfig['syntax']) => void {\n const { options: opts, parentUrl } = params;\n\n // Ensure options is always an object before spreading\n const { rootDir, ...options } = (opts && typeof opts === 'object' ? opts : {}) as Partial<\n NonNullable<AppConfig['relay']>\n >;\n\n if (!rootDir) {\n throw new Error('The relay capability requires a rootDir option to be set.');\n }\n\n const relayPlugin = fileURLToPath(resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl }));\n\n return (swcConfig, syntax) => {\n const relayConfig: SwcRelayConfig = {\n // This must be set or bundlers may default to \"require\" instead of inlining\n eagerEsModules: true,\n ...options,\n rootDir,\n language: syntax === 'typescript' ? 'typescript' : ('javascript' as 'javascrip'), // typo in plugin types\n };\n\n swcConfig.jsc ??= {};\n swcConfig.jsc.experimental ??= {};\n swcConfig.jsc.experimental.plugins ??= [];\n swcConfig.jsc.experimental.plugins.push([relayPlugin, relayConfig]);\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { defaultTargetSyntax } from './constants.js';
|
|
2
2
|
export { getModuleSearchPaths } from './getModuleSearchPaths.js';
|
|
3
3
|
export { getSwcConfig } from './getSwcConfig.js';
|
|
4
|
+
export { getSwcRelayPluginConfig } from './getSwcRelayPluginConfig.js';
|
|
4
5
|
export { shouldExternalizePackage } from './shouldExternalizePackage.js';
|
|
5
6
|
export { getCssRule } from './getCssRule.js';
|
|
6
7
|
export { processAssetInlineExtensions } from './processAssetInlineExtensions.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { defaultTargetSyntax } from './constants.js';
|
|
2
2
|
export { getModuleSearchPaths } from './getModuleSearchPaths.js';
|
|
3
3
|
export { getSwcConfig } from './getSwcConfig.js';
|
|
4
|
+
export { getSwcRelayPluginConfig } from './getSwcRelayPluginConfig.js';
|
|
4
5
|
export { shouldExternalizePackage } from './shouldExternalizePackage.js';
|
|
5
6
|
export { getCssRule } from './getCssRule.js';
|
|
6
7
|
export { processAssetInlineExtensions } from './processAssetInlineExtensions.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { defaultTargetSyntax } from './constants.js';\nexport { getModuleSearchPaths } from './getModuleSearchPaths.js';\nexport { getSwcConfig } from './getSwcConfig.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\nexport { getCssRule } from './getCssRule.js';\nexport { processAssetInlineExtensions } from './processAssetInlineExtensions.js';\nexport { requiresTranspile } from './requiresTranspile.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { defaultTargetSyntax } from './constants.js';\nexport { getModuleSearchPaths } from './getModuleSearchPaths.js';\nexport { getSwcConfig } from './getSwcConfig.js';\nexport { getSwcRelayPluginConfig } from './getSwcRelayPluginConfig.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\nexport { getCssRule } from './getCssRule.js';\nexport { processAssetInlineExtensions } from './processAssetInlineExtensions.js';\nexport { requiresTranspile } from './requiresTranspile.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler-utilities",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"description": "Utilities used by multiple Cloudpack bundlers implementations",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@ms-cloudpack/json-utilities": "^0.1.11",
|
|
28
|
-
"@ms-cloudpack/package-utilities": "^13.3.
|
|
28
|
+
"@ms-cloudpack/package-utilities": "^13.3.6",
|
|
29
29
|
"@ms-cloudpack/path-string-parsing": "^1.3.0",
|
|
30
30
|
"@ms-cloudpack/path-utilities": "^3.2.5",
|
|
31
31
|
"get-tsconfig": "^4.7.2",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
37
37
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
38
38
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|
|
39
|
-
"@swc/core": "^1.3.0"
|
|
39
|
+
"@swc/core": "^1.3.0",
|
|
40
|
+
"@swc/plugin-relay": "^9.0.0"
|
|
40
41
|
},
|
|
41
42
|
"files": [
|
|
42
43
|
"lib/**/!(*.test.*)"
|