@ms-cloudpack/bundler 0.16.1 → 0.17.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/README.md +1 -1
- package/lib/bundle.d.ts.map +1 -1
- package/lib/bundle.js +4 -2
- package/lib/bundle.js.map +1 -1
- package/lib/chooseBundler.d.ts +4 -1
- package/lib/chooseBundler.d.ts.map +1 -1
- package/lib/chooseBundler.js +3 -5
- package/lib/chooseBundler.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ This library has only 2 output modes:
|
|
|
56
56
|
|
|
57
57
|
- library mode - produces a bundle of source which externalizes dependencies and is consumable by the target (browser or node) which
|
|
58
58
|
can resolve the dependencies through an import maps in the browser or through module resolution in node. The source is unminified.
|
|
59
|
-
- production mode - produces a bundle of source which includes dependencies and is also similarly
|
|
59
|
+
- production mode - produces a bundle of source which includes dependencies and is also similarly consumed.
|
|
60
60
|
|
|
61
61
|
### Package requirements
|
|
62
62
|
|
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,MAAM,6BAA6B,CAAC;
|
|
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;AAK9F;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAsEhH"}
|
package/lib/bundle.js
CHANGED
|
@@ -2,6 +2,7 @@ import { chooseBundler } from './chooseBundler.js';
|
|
|
2
2
|
import {} from '@ms-cloudpack/config-types';
|
|
3
3
|
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { detectModuleType } from '@ms-cloudpack/package-utilities';
|
|
5
6
|
/**
|
|
6
7
|
* Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more
|
|
7
8
|
* advanced api surface.
|
|
@@ -36,11 +37,12 @@ export async function bundle(options, context) {
|
|
|
36
37
|
return { errors: configErrors };
|
|
37
38
|
}
|
|
38
39
|
// Choose the bundler type and bundle.
|
|
40
|
+
const moduleType = await detectModuleType(path.resolve(options.inputPath, Object.values(options.entries)[0]));
|
|
39
41
|
const { outputPath = options.inputPath } = options;
|
|
40
|
-
const bundler = await chooseBundler(options);
|
|
42
|
+
const bundler = await chooseBundler(options, { moduleType });
|
|
41
43
|
let result = undefined;
|
|
42
44
|
try {
|
|
43
|
-
result = await bundler.bundle(options, context);
|
|
45
|
+
result = await bundler.bundle(options, { ...context, moduleType });
|
|
44
46
|
}
|
|
45
47
|
catch (e) {
|
|
46
48
|
result = {
|
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;
|
|
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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C,EAAE,SAAS,CAAC;SACxF,CAAC,CAAC;KACJ;IAED,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW,IAAI,EAAE,EAAE;QACjD,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;KAC1E;IAED,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,IAAI;QACzB,SAAS,EAAE,OAAO,CAAC,SAAS;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';\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 { errors: configErrors };\n }\n\n // Choose the bundler type and bundle.\n const moduleType = await detectModuleType(path.resolve(options.inputPath, Object.values(options.entries)[0]));\n const { outputPath = options.inputPath } = options;\n const bundler = await chooseBundler(options, { moduleType });\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\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,8 +1,11 @@
|
|
|
1
1
|
import type { Bundler, BundleOptions } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { ModuleType } from '@ms-cloudpack/package-utilities';
|
|
2
3
|
/**
|
|
3
4
|
* Mediates which bundler to use.
|
|
4
5
|
* @param options Bundler options, defining what we expect to bundle and how.
|
|
5
6
|
* @returns A bundler plugin.
|
|
6
7
|
*/
|
|
7
|
-
export declare function chooseBundler(options: BundleOptions
|
|
8
|
+
export declare function chooseBundler(options: BundleOptions, context: {
|
|
9
|
+
moduleType: ModuleType;
|
|
10
|
+
}): Promise<Bundler>;
|
|
8
11
|
//# sourceMappingURL=chooseBundler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAcjH"}
|
package/lib/chooseBundler.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { allBundlers } from './allBundlers.js';
|
|
3
|
-
import { detectModuleType } from '@ms-cloudpack/package-utilities';
|
|
4
2
|
/**
|
|
5
3
|
* Mediates which bundler to use.
|
|
6
4
|
* @param options Bundler options, defining what we expect to bundle and how.
|
|
7
5
|
* @returns A bundler plugin.
|
|
8
6
|
*/
|
|
9
|
-
export async function chooseBundler(options) {
|
|
10
|
-
const { bundlerType
|
|
7
|
+
export async function chooseBundler(options, context) {
|
|
8
|
+
const { bundlerType } = options;
|
|
9
|
+
const { moduleType } = context;
|
|
11
10
|
const { rollup, ori } = allBundlers;
|
|
12
11
|
if (!bundlerType || bundlerType === 'auto') {
|
|
13
|
-
const moduleType = await detectModuleType(path.resolve(inputPath, Object.values(entries)[0]));
|
|
14
12
|
if (moduleType === 'cjs') {
|
|
15
13
|
return await rollup();
|
|
16
14
|
}
|
package/lib/chooseBundler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chooseBundler.js","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chooseBundler.js","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,OAAmC;IAC7F,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;IAEpC,IAAI,CAAC,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1C,IAAI,UAAU,KAAK,KAAK,EAAE;YACxB,OAAO,MAAM,MAAM,EAAE,CAAC;SACvB;QAED,OAAO,MAAM,GAAG,EAAE,CAAC;KACpB;IAED,OAAO,MAAM,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type { Bundler, BundleOptions } from '@ms-cloudpack/bundler-types';\nimport { allBundlers } from './allBundlers.js';\nimport type { ModuleType } from '@ms-cloudpack/package-utilities';\n\n/**\n * Mediates which bundler to use.\n * @param options Bundler options, defining what we expect to bundle and how.\n * @returns A bundler plugin.\n */\nexport async function chooseBundler(options: BundleOptions, context: { moduleType: ModuleType }): Promise<Bundler> {\n const { bundlerType } = options;\n const { moduleType } = context;\n const { rollup, ori } = allBundlers;\n\n if (!bundlerType || bundlerType === 'auto') {\n if (moduleType === 'cjs') {\n return await rollup();\n }\n\n return await ori();\n }\n\n return await allBundlers[bundlerType]();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "An abstraction to bundle source code.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/json-utilities": "^0.1.
|
|
18
|
-
"@ms-cloudpack/bundler-plugin-ori": "^0.
|
|
19
|
-
"@ms-cloudpack/bundler-plugin-rollup": "^0.7.
|
|
20
|
-
"@ms-cloudpack/bundler-types": "^
|
|
21
|
-
"@ms-cloudpack/config": "^0.17.
|
|
22
|
-
"@ms-cloudpack/config-types": "^0.1.
|
|
23
|
-
"@ms-cloudpack/package-utilities": "^5.
|
|
17
|
+
"@ms-cloudpack/json-utilities": "^0.1.2",
|
|
18
|
+
"@ms-cloudpack/bundler-plugin-ori": "^0.14.0",
|
|
19
|
+
"@ms-cloudpack/bundler-plugin-rollup": "^0.7.37",
|
|
20
|
+
"@ms-cloudpack/bundler-types": "^0.23.0",
|
|
21
|
+
"@ms-cloudpack/config": "^0.17.2",
|
|
22
|
+
"@ms-cloudpack/config-types": "^0.1.1",
|
|
23
|
+
"@ms-cloudpack/package-utilities": "^5.6.0",
|
|
24
24
|
"@ms-cloudpack/path-string-parsing": "^1.1.1",
|
|
25
25
|
"@ms-cloudpack/path-utilities": "^2.3.5"
|
|
26
26
|
},
|