@ms-cloudpack/bundler 0.18.0 → 0.18.1-beta.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.
- package/lib/allBundlers.d.ts +2 -2
- package/lib/allBundlers.d.ts.map +1 -1
- package/lib/allBundlers.js.map +1 -1
- package/lib/bundle.d.ts +1 -9
- package/lib/bundle.d.ts.map +1 -1
- package/lib/bundle.js +32 -25
- package/lib/bundle.js.map +1 -1
- package/lib/chooseBundler.d.ts +3 -3
- package/lib/chooseBundler.d.ts.map +1 -1
- package/lib/chooseBundler.js +1 -1
- package/lib/chooseBundler.js.map +1 -1
- package/lib/getEntriesMapFromPackage.d.ts +1 -1
- package/lib/getEntriesMapFromPackage.d.ts.map +1 -1
- package/lib/getEntriesMapFromPackage.js +8 -8
- package/lib/getEntriesMapFromPackage.js.map +1 -1
- package/package.json +3 -3
- package/lib/tsdoc-metadata.json +0 -11
package/lib/allBundlers.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const allBundlers: Record<string, () => Promise<
|
|
1
|
+
import type { Bundler } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
export declare const allBundlers: Record<string, () => Promise<Bundler>>;
|
|
3
3
|
//# sourceMappingURL=allBundlers.d.ts.map
|
package/lib/allBundlers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allBundlers.d.ts","sourceRoot":"","sources":["../src/allBundlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"allBundlers.d.ts","sourceRoot":"","sources":["../src/allBundlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAI9D,CAAC"}
|
package/lib/allBundlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allBundlers.js","sourceRoot":"","sources":["../src/allBundlers.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"allBundlers.js","sourceRoot":"","sources":["../src/allBundlers.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAA2C;IACjE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC,OAAO;IACjF,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC,OAAO;IAC3E,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO;CACpF,CAAC","sourcesContent":["import type { Bundler } from '@ms-cloudpack/bundler-types';\n\nexport const allBundlers: Record<string, () => Promise<Bundler>> = {\n rollup: async () => (await import('@ms-cloudpack/bundler-plugin-rollup')).default,\n ori: async () => (await import('@ms-cloudpack/bundler-plugin-ori')).default,\n webpack: async () => (await import('@ms-cloudpack/bundler-plugin-webpack')).default,\n};\n"]}
|
package/lib/bundle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
2
|
-
import type { BundleOptions, BundleResult
|
|
2
|
+
import type { BundleOptions, BundleResult } from '@ms-cloudpack/bundler-types';
|
|
3
3
|
/**
|
|
4
4
|
* Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more
|
|
5
5
|
* advanced api surface.
|
|
@@ -7,12 +7,4 @@ import type { BundleOptions, BundleResult, BundlerPluginResult } from '@ms-cloud
|
|
|
7
7
|
export declare function bundle(options: BundleOptions, context: {
|
|
8
8
|
config: CloudpackConfig;
|
|
9
9
|
}): Promise<BundleResult>;
|
|
10
|
-
/**
|
|
11
|
-
* Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic
|
|
12
|
-
* between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),
|
|
13
|
-
* and helps with testing.
|
|
14
|
-
*/
|
|
15
|
-
export declare function bundleInternal(pluginBundle: () => Promise<BundlerPluginResult>, options: BundleOptions & {
|
|
16
|
-
bundlerName: string;
|
|
17
|
-
}): Promise<BundleResult>;
|
|
18
10
|
//# sourceMappingURL=bundle.d.ts.map
|
package/lib/bundle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAiB,aAAa,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAiB,aAAa,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM9F;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAkFhH"}
|
package/lib/bundle.js
CHANGED
|
@@ -43,37 +43,44 @@ export async function bundle(options, context) {
|
|
|
43
43
|
? await detectModuleType(path.resolve(options.inputPath, firstSourceEntry))
|
|
44
44
|
: undefined;
|
|
45
45
|
const isTypescript = firstSourceEntry ? typescriptExtensions.includes(path.extname(firstSourceEntry)) : false;
|
|
46
|
+
const { outputPath = options.inputPath } = options;
|
|
46
47
|
const bundler = await chooseBundler({ bundlerType: options.bundlerType, moduleType, isTypescript });
|
|
47
|
-
|
|
48
|
-
return bundleInternal(bundleFunc, { ...options, bundlerName: bundler.name });
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic
|
|
52
|
-
* between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),
|
|
53
|
-
* and helps with testing.
|
|
54
|
-
*/
|
|
55
|
-
export async function bundleInternal(pluginBundle, options) {
|
|
56
|
-
let pluginResult = undefined;
|
|
48
|
+
let result = undefined;
|
|
57
49
|
try {
|
|
58
|
-
|
|
50
|
+
result = await bundler.bundle(options, { ...context, moduleType });
|
|
59
51
|
}
|
|
60
52
|
catch (e) {
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
result = {
|
|
54
|
+
bundlerName: bundler.name,
|
|
55
|
+
inputPath: options.inputPath,
|
|
56
|
+
entries: options.entries,
|
|
57
|
+
errors: [
|
|
58
|
+
{
|
|
59
|
+
text: `Unexpected exception: ${e}`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
finally {
|
|
65
|
+
const { errors, rawInput, rawOutput } = result || {};
|
|
66
|
+
await Promise.all([
|
|
67
|
+
errors?.length && writeJson(path.join(outputPath, `${bundler.name}-errors.json`), errors),
|
|
68
|
+
rawInput && writeJson(path.join(outputPath, `${bundler.name}-input.json`), rawInput),
|
|
69
|
+
rawOutput && writeJson(path.join(outputPath, `${bundler.name}-output.json`), rawOutput),
|
|
70
|
+
]);
|
|
71
|
+
// Clear raw input and output from the result returned to eliminate excessive memory usage.
|
|
72
|
+
if (result) {
|
|
73
|
+
result.rawInput = result.rawOutput = undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const outputFile of result.outputFiles || []) {
|
|
77
|
+
outputFile.outputPath = path.relative(outputPath, outputFile.outputPath);
|
|
76
78
|
}
|
|
77
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
bundlerName: bundler.name,
|
|
81
|
+
inputPath: options.inputPath,
|
|
82
|
+
entries: options.entries,
|
|
83
|
+
...result,
|
|
84
|
+
};
|
|
78
85
|
}
|
|
79
86
|
//# sourceMappingURL=bundle.js.map
|
package/lib/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,OAAoC;IACvF,MAAM,YAAY,GAAoB,EAAE,CAAC;IAEzC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAC/B,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mCAAmC;SAC1C,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/C,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,8BAA8B;SACrC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/C,YAA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S;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAI,MAAgC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import { chooseBundler } from './chooseBundler.js';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { BundleMessage, BundleOptions, BundleResult } from '@ms-cloudpack/bundler-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { detectModuleType } from '@ms-cloudpack/package-utilities';\nimport { sourceExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities';\n\n/**\n * Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more\n * advanced api surface.\n */\nexport async function bundle(options: BundleOptions, context: { config: CloudpackConfig }): Promise<BundleResult> {\n const configErrors: BundleMessage[] = [];\n\n if (!options.inputPath?.length) {\n configErrors.push({\n type: 'invalid-input',\n text: 'No input path provided to bundle.',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n type: 'input-relative',\n text: 'Input path must be absolute.',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n type: 'no-entries',\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n type: 'entry-absolute',\n text: `Entry paths must be relative.`,\n });\n }\n\n if (configErrors.length) {\n return { inputPath: options.inputPath, errors: configErrors };\n }\n\n // Choose the bundler type and bundle.\n const firstSourceEntry = Object.values(options.entries).find((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n const moduleType = firstSourceEntry\n ? await detectModuleType(path.resolve(options.inputPath, firstSourceEntry))\n : undefined;\n const isTypescript = firstSourceEntry ? typescriptExtensions.includes(path.extname(firstSourceEntry)) : false;\n\n const { outputPath = options.inputPath } = options;\n const bundler = await chooseBundler({ bundlerType: options.bundlerType, moduleType, isTypescript });\n let result: BundleResult | undefined = undefined;\n\n try {\n result = await bundler.bundle(options, { ...context, moduleType });\n } catch (e) {\n result = {\n bundlerName: bundler.name,\n inputPath: options.inputPath,\n entries: options.entries,\n errors: [\n {\n text: `Unexpected exception: ${e}`,\n },\n ],\n };\n } finally {\n const { errors, rawInput, rawOutput } = result || {};\n\n await Promise.all([\n errors?.length && writeJson(path.join(outputPath, `${bundler.name}-errors.json`), errors),\n rawInput && writeJson(path.join(outputPath, `${bundler.name}-input.json`), rawInput),\n rawOutput && writeJson(path.join(outputPath, `${bundler.name}-output.json`), rawOutput),\n ]);\n\n // Clear raw input and output from the result returned to eliminate excessive memory usage.\n if (result) {\n result.rawInput = result.rawOutput = undefined;\n }\n }\n\n for (const outputFile of result.outputFiles || []) {\n outputFile.outputPath = path.relative(outputPath, outputFile.outputPath);\n }\n\n return {\n bundlerName: bundler.name,\n inputPath: options.inputPath,\n entries: options.entries,\n ...(result as Partial<BundleResult>),\n };\n}\n"]}
|
package/lib/chooseBundler.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Bundler } from '@ms-cloudpack/bundler-types';
|
|
2
2
|
import type { ModuleType } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
/**
|
|
4
|
-
* Determines which bundler
|
|
4
|
+
* Determines which bundler to use.
|
|
5
5
|
* @returns A bundler plugin.
|
|
6
6
|
*/
|
|
7
7
|
export declare function chooseBundler(params: {
|
|
8
8
|
bundlerType: string | undefined;
|
|
9
9
|
moduleType: ModuleType;
|
|
10
10
|
isTypescript: boolean;
|
|
11
|
-
}): Promise<
|
|
11
|
+
}): Promise<Bundler>;
|
|
12
12
|
//# sourceMappingURL=chooseBundler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,OAAO,CAAC,CAanB"}
|
package/lib/chooseBundler.js
CHANGED
package/lib/chooseBundler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chooseBundler.js","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAInC;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;IAEpC,IAAI,CAAC,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1C,OAAO,MAAM,MAAM,EAAE,CAAC;QACxB,CAAC;QAED,OAAO,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"chooseBundler.js","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAInC;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;IAEpC,IAAI,CAAC,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1C,OAAO,MAAM,MAAM,EAAE,CAAC;QACxB,CAAC;QAED,OAAO,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type { Bundler } from '@ms-cloudpack/bundler-types';\nimport type { ModuleType } from '@ms-cloudpack/package-utilities';\nimport { allBundlers } from './allBundlers.js';\n\n/**\n * Determines which bundler to use.\n * @returns A bundler plugin.\n */\nexport async function chooseBundler(params: {\n bundlerType: string | undefined;\n moduleType: ModuleType;\n isTypescript: boolean;\n}): Promise<Bundler> {\n const { bundlerType, moduleType, isTypescript } = params;\n const { rollup, ori } = allBundlers;\n\n if (!bundlerType || bundlerType === 'auto') {\n if (moduleType === 'cjs' && !isTypescript) {\n return await rollup();\n }\n\n return await ori();\n }\n\n return await allBundlers[bundlerType]();\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
1
|
import { type CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
2
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the entries map for a given package. An entries map is different from an exports map in that
|
|
5
5
|
* the keys are relative paths to where the output should live, rather than how the entry is imported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntriesMapFromPackage.d.ts","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEntriesMapFromPackage.d.ts","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgCjC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {} from '@ms-cloudpack/config-types';
|
|
2
1
|
import { flattenExportsMap, getExportsMap, isExternalPackage } from '@ms-cloudpack/package-utilities';
|
|
3
|
-
import {
|
|
2
|
+
import {} from '@ms-cloudpack/config-types';
|
|
4
3
|
import { intermediateToSourcePath, sourceExtensions } from '@ms-cloudpack/path-utilities';
|
|
5
|
-
import path from 'path';
|
|
6
4
|
import { isValidBundleEntry } from './isValidBundleEntry.js';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
7
7
|
/**
|
|
8
8
|
* Gets the entries map for a given package. An entries map is different from an exports map in that
|
|
9
9
|
* the keys are relative paths to where the output should live, rather than how the entry is imported.
|
|
@@ -31,25 +31,25 @@ export async function getEntriesMapFromPackage(options, context) {
|
|
|
31
31
|
return Object.fromEntries(Object.entries(flattenedMap)
|
|
32
32
|
.filter(([, value]) => isValidBundleEntry(value))
|
|
33
33
|
.map(([key, value]) => [
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
toSafeEntryKey(value),
|
|
35
|
+
makeSafeRelativePath(inputPath, sourceExportsMap?.[key] || value),
|
|
36
36
|
]));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler
|
|
40
40
|
* will add back `'.js'` for us in the output.
|
|
41
41
|
*/
|
|
42
|
-
function
|
|
42
|
+
function toSafeEntryKey(entry) {
|
|
43
43
|
const extension = path.extname(entry);
|
|
44
44
|
if (sourceExtensions.includes(extension)) {
|
|
45
45
|
return entry.slice(0, -extension.length);
|
|
46
46
|
}
|
|
47
47
|
return entry;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function makeSafeRelativePath(inputPath, entry) {
|
|
50
50
|
if (path.isAbsolute(entry)) {
|
|
51
51
|
entry = path.relative(inputPath, entry);
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return safeRelativePath(entry);
|
|
54
54
|
}
|
|
55
55
|
//# sourceMappingURL=getEntriesMapFromPackage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntriesMapFromPackage.js","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEntriesMapFromPackage.js","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAEC,EACD,OAGC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,UAAU,GAAG,CAAC,iBAAiB,CAAC,SAA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ACtC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAiB,EAAE,KAAa;IAC5D,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { flattenExportsMap, getExportsMap, isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { intermediateToSourcePath, sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport { isValidBundleEntry } from './isValidBundleEntry.js';\nimport path from 'path';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Gets the entries map for a given package. An entries map is different from an exports map in that\n * the keys are relative paths to where the output should live, rather than how the entry is imported.\n * The data structure is used for bundler config; not for resolution of imports.\n */\nexport async function getEntriesMapFromPackage(\n options: {\n inputPath: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n },\n): Promise<Record<string, string>> {\n const { inputPath } = options;\n const isInternal = !isExternalPackage(inputPath);\n const exportsMap = await getExportsMap({ packagePath: inputPath }, context);\n const flattenedMap = flattenExportsMap(exportsMap);\n let sourceExportsMap: Record<string, string>;\n\n // The flattened map values tell us what physical files will show up in the import map on the page. We use these\n // as the keys for the entries map, which results in physical file output from the bundler.\n\n // For internal packages, we want the values (the inputs to the each entry) to use source paths if available. To\n // get these, we can either derive from exports map \"source\" entries, or if those are not available, we can attempt\n // to derive source paths from intermediate paths.\n\n if (isInternal) {\n sourceExportsMap = flattenExportsMap(exportsMap, { conditions: ['source'], requiredConditions: ['source'] });\n\n for (const [key, value] of Object.entries(flattenedMap)) {\n if (!sourceExportsMap[key]) {\n sourceExportsMap[key] = intermediateToSourcePath(value, inputPath) || value;\n }\n }\n }\n\n return Object.fromEntries(\n Object.entries(flattenedMap)\n .filter(([, value]) => isValidBundleEntry(value))\n .map(([key, value]) => [\n toSafeEntryKey(value),\n makeSafeRelativePath(inputPath, sourceExportsMap?.[key] || value),\n ]),\n );\n}\n\n/**\n * When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler\n * will add back `'.js'` for us in the output.\n */\nfunction toSafeEntryKey(entry: string): string {\n const extension = path.extname(entry);\n if (sourceExtensions.includes(extension)) {\n return entry.slice(0, -extension.length);\n }\n\n return entry;\n}\n\nfunction makeSafeRelativePath(inputPath: string, entry: string): string {\n if (path.isAbsolute(entry)) {\n entry = path.relative(inputPath, entry);\n }\n\n return safeRelativePath(entry);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler",
|
|
3
|
-
"version": "0.18.0",
|
|
3
|
+
"version": "0.18.1-beta.0",
|
|
4
4
|
"description": "An abstraction to bundle source code.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
18
18
|
"@ms-cloudpack/bundler-plugin-ori": "^0.15.0",
|
|
19
|
-
"@ms-cloudpack/bundler-plugin-rollup": "^0.11.0",
|
|
20
|
-
"@ms-cloudpack/bundler-plugin-webpack": "^0.2.0",
|
|
19
|
+
"@ms-cloudpack/bundler-plugin-rollup": "^0.11.1-beta.0",
|
|
20
|
+
"@ms-cloudpack/bundler-plugin-webpack": "^0.2.1-beta.0",
|
|
21
21
|
"@ms-cloudpack/bundler-types": "^0.25.0",
|
|
22
22
|
"@ms-cloudpack/config": "^0.17.32",
|
|
23
23
|
"@ms-cloudpack/config-types": "^0.5.1",
|
package/lib/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.39.4"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|