@ms-cloudpack/bundler 0.21.1 → 0.21.3
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/bundle.d.ts.map +1 -1
- package/lib/bundle.js +4 -4
- package/lib/bundle.js.map +1 -1
- package/lib/chooseBundler.d.ts +1 -2
- package/lib/chooseBundler.d.ts.map +1 -1
- package/lib/chooseBundler.js +2 -1
- package/lib/chooseBundler.js.map +1 -1
- package/package.json +8 -8
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,KAAK,EAEV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAMpC;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAyDhH;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,EAChD,OAAO,EAAE,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/C,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
|
package/lib/bundle.js
CHANGED
|
@@ -39,11 +39,11 @@ export async function bundle(options, context) {
|
|
|
39
39
|
// Choose the bundler type and bundle.
|
|
40
40
|
const sourceEntries = Object.values(options.entries).filter((fileName) => sourceExtensions.includes(path.extname(fileName)));
|
|
41
41
|
let moduleType = 'esm';
|
|
42
|
-
//
|
|
42
|
+
// Check the module type of each entry, short circuiting if we find a cjs or amd file.
|
|
43
43
|
for (const sourceEntry of sourceEntries) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const sourceType = await detectModuleType(path.resolve(options.inputPath, sourceEntry));
|
|
45
|
+
if (sourceType === 'amd' || sourceType === 'cjs') {
|
|
46
|
+
moduleType = sourceType;
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
}
|
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;
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASnD,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,mCAAmC;YACzC,MAAM,EAAE,QAAQ;SACjB,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,8BAA8B;YACpC,MAAM,EAAE,QAAQ;SACjB,CAAC,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,IAAI,OAAO,EAAE,CAAC;QACZ,2CAA2C;QAC3C,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { chooseBundler } from './chooseBundler.js';\nimport type {\n BundleMessage,\n BundleOptions,\n BundleResult,\n BundlerPluginResult,\n CloudpackConfig,\n ModuleType,\n} from '@ms-cloudpack/common-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 text: 'No input path provided to bundle.',\n source: 'bundle',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n text: 'Input path must be absolute.',\n source: 'bundle',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n source: 'bundle',\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n text: `Entry paths must be relative.`,\n source: 'bundle',\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 sourceEntries = Object.values(options.entries).filter((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n\n let moduleType: ModuleType = 'esm';\n\n // Check the module type of each entry, short circuiting if we find a cjs or amd file.\n for (const sourceEntry of sourceEntries) {\n const sourceType = await detectModuleType(path.resolve(options.inputPath, sourceEntry));\n if (sourceType === 'amd' || sourceType === 'cjs') {\n moduleType = sourceType;\n break;\n }\n }\n\n const isTypescript = sourceEntries.some((fileName) => typescriptExtensions.includes(path.extname(fileName)));\n\n const bundler = await chooseBundler({\n bundlerType: options.bundlerType,\n mode: context.config.mode,\n moduleType,\n isTypescript,\n });\n const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });\n return bundleInternal(bundleFunc, { ...options, bundlerName: bundler.name });\n}\n\n/**\n * Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic\n * between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),\n * and helps with testing.\n */\nexport async function bundleInternal(\n pluginBundle: () => Promise<BundlerPluginResult>,\n options: BundleOptions & { bundlerName: string },\n): Promise<BundleResult> {\n let pluginResult: BundlerPluginResult | undefined = undefined;\n\n try {\n pluginResult = await pluginBundle();\n } catch (e) {\n const errorMessage: BundleMessage = { text: `Exception while bundling: ${e}`, source: options.bundlerName };\n if (e instanceof Error && e.stack) {\n // remove the message from the stack\n errorMessage.notes = [{ text: e.stack.includes(e.message) ? e.stack.split(e.message)[1] : '' }];\n }\n pluginResult = {\n errors: [errorMessage],\n };\n }\n\n const { rawInput, rawOutput, rebuild, ...rest } = pluginResult || {};\n const { bundlerName, inputPath, entries, outputPath: logOutputPath = inputPath } = options;\n\n await Promise.all([\n rest.errors?.length && writeJson(path.join(logOutputPath, `${bundlerName}-errors.json`), rest.errors),\n rawInput && writeJson(path.join(logOutputPath, `${bundlerName}-input.json`), rawInput),\n rawOutput && writeJson(path.join(logOutputPath, `${bundlerName}-output.json`), rawOutput),\n ]);\n\n const result: BundleResult = { bundlerName, inputPath, entries, ...rest };\n if (options.ignoredBundlerWarnings?.length && result.warnings?.length) {\n result.warnings = result.warnings.filter(\n (warning) => !options.ignoredBundlerWarnings?.some((suppressed) => warning.text.includes(suppressed)),\n );\n }\n\n if (rebuild) {\n // Wrap rebuild with proper result handling\n result.rebuild = () => bundleInternal(rebuild, options);\n }\n\n return result;\n}\n"]}
|
package/lib/chooseBundler.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { BundleMode, BundlerPlugin } from '@ms-cloudpack/common-types';
|
|
2
|
-
import type { ModuleType } from '@ms-cloudpack/package-utilities';
|
|
1
|
+
import type { BundleMode, BundlerPlugin, ModuleType } from '@ms-cloudpack/common-types';
|
|
3
2
|
/**
|
|
4
3
|
* Determines which bundler plugin to use.
|
|
5
4
|
* @returns A bundler plugin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"chooseBundler.d.ts","sourceRoot":"","sources":["../src/chooseBundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxF;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,OAAO,CAAC,aAAa,CAAC,CAkBzB"}
|
package/lib/chooseBundler.js
CHANGED
|
@@ -7,9 +7,10 @@ export async function chooseBundler(params) {
|
|
|
7
7
|
const { bundlerType, moduleType, isTypescript, mode } = params;
|
|
8
8
|
const { rollup, ori, webpack } = allBundlers;
|
|
9
9
|
if (!bundlerType || bundlerType === 'auto') {
|
|
10
|
-
if (mode === 'production') {
|
|
10
|
+
if (mode === 'production' || moduleType === 'amd') {
|
|
11
11
|
return await webpack();
|
|
12
12
|
}
|
|
13
|
+
// TODO do we still need !isTypescript now that rollup handles typescript?
|
|
13
14
|
if (moduleType === 'cjs' && !isTypescript) {
|
|
14
15
|
return await rollup();
|
|
15
16
|
}
|
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;AAE/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAKnC;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;IAE7C,IAAI,CAAC,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3C,IAAI,IAAI,KAAK,YAAY,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YAClD,OAAO,MAAM,OAAO,EAAE,CAAC;QACzB,CAAC;QAED,0EAA0E;QAC1E,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 { BundleMode, BundlerPlugin, ModuleType } from '@ms-cloudpack/common-types';\nimport { allBundlers } from './allBundlers.js';\n\n/**\n * Determines which bundler plugin to use.\n * @returns A bundler plugin.\n */\nexport async function chooseBundler(params: {\n bundlerType: string | undefined;\n moduleType: ModuleType;\n isTypescript: boolean;\n mode?: BundleMode;\n}): Promise<BundlerPlugin> {\n const { bundlerType, moduleType, isTypescript, mode } = params;\n const { rollup, ori, webpack } = allBundlers;\n\n if (!bundlerType || bundlerType === 'auto') {\n if (mode === 'production' || moduleType === 'amd') {\n return await webpack();\n }\n\n // TODO do we still need !isTypescript now that rollup handles typescript?\n if (moduleType === 'cjs' && !isTypescript) {\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.21.
|
|
3
|
+
"version": "0.21.3",
|
|
4
4
|
"description": "An abstraction to bundle source code.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-plugin-ori": "^0.18.
|
|
18
|
-
"@ms-cloudpack/bundler-plugin-rollup": "^0.13.
|
|
19
|
-
"@ms-cloudpack/bundler-plugin-webpack": "^0.5.
|
|
20
|
-
"@ms-cloudpack/common-types": "^0.
|
|
21
|
-
"@ms-cloudpack/config": "^0.
|
|
17
|
+
"@ms-cloudpack/bundler-plugin-ori": "^0.18.3",
|
|
18
|
+
"@ms-cloudpack/bundler-plugin-rollup": "^0.13.34",
|
|
19
|
+
"@ms-cloudpack/bundler-plugin-webpack": "^0.5.3",
|
|
20
|
+
"@ms-cloudpack/common-types": "^0.9.0",
|
|
21
|
+
"@ms-cloudpack/config": "^0.22.0",
|
|
22
22
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
23
|
-
"@ms-cloudpack/package-utilities": "^7.
|
|
23
|
+
"@ms-cloudpack/package-utilities": "^7.7.1",
|
|
24
24
|
"@ms-cloudpack/path-string-parsing": "^1.2.3",
|
|
25
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
25
|
+
"@ms-cloudpack/path-utilities": "^2.7.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|