@ms-cloudpack/bundler-rollup 0.4.2 → 0.4.4
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/getRollupOptions.d.ts +4 -4
- package/lib/getRollupOptions.d.ts.map +1 -1
- package/lib/getRollupOptions.js +5 -9
- package/lib/getRollupOptions.js.map +1 -1
- package/lib/getRollupPlugins.d.ts +5 -5
- package/lib/getRollupPlugins.d.ts.map +1 -1
- package/lib/getRollupPlugins.js +21 -19
- package/lib/getRollupPlugins.js.map +1 -1
- package/lib/rollup.js +1 -1
- package/lib/rollup.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';
|
|
2
2
|
import type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';
|
|
3
3
|
import type { OutputOptions, RollupLog, RollupOptions } from 'rollup';
|
|
4
4
|
/**
|
|
@@ -6,11 +6,11 @@ import type { OutputOptions, RollupLog, RollupOptions } from 'rollup';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function getRollupOptions(params: {
|
|
8
8
|
options: Omit<BundleOptions, 'entries'>;
|
|
9
|
-
|
|
10
|
-
} & Pick<WriteESMStubsResult, 'newEntries'>):
|
|
9
|
+
context: BundleContext;
|
|
10
|
+
} & Pick<WriteESMStubsResult, 'newEntries'>): {
|
|
11
11
|
inputOptions: RollupOptions;
|
|
12
12
|
outputOptions: OutputOptions;
|
|
13
13
|
/** Warnings will be pushed to this array (rollup handles warnings with a callback) */
|
|
14
14
|
warnings: RollupLog[];
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
//# sourceMappingURL=getRollupOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupOptions.d.ts","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getRollupOptions.d.ts","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAgB,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAUpF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IACN,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAC1C;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,sFAAsF;IACtF,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,CAkEA"}
|
package/lib/getRollupOptions.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';
|
|
2
|
-
import { isExternalPackage } from '@ms-cloudpack/path-utilities';
|
|
3
|
-
import fs from 'fs';
|
|
4
2
|
import path from 'path';
|
|
5
3
|
import { getRollupPlugins } from './getRollupPlugins.js';
|
|
6
4
|
// These are the polyfills that we support from the 'rollup-plugin-polyfill-node' plugin
|
|
@@ -11,11 +9,9 @@ const ignoredWarnings = ['Circular dependency:'];
|
|
|
11
9
|
/**
|
|
12
10
|
* Converts BundlerOptions to Rollup-specific options.
|
|
13
11
|
*/
|
|
14
|
-
export
|
|
15
|
-
const { options, newEntries } = params;
|
|
12
|
+
export function getRollupOptions(params) {
|
|
13
|
+
const { options, context, newEntries } = params;
|
|
16
14
|
const { inputPath, minify, external = [], inlined = [], bundlerOptions = {}, dynamicImports, sourcemap, bundlerCapabilities, } = options;
|
|
17
|
-
const isExternal = isExternalPackage(inputPath);
|
|
18
|
-
const enableTypescript = !isExternal && fs.existsSync(path.resolve(inputPath, 'tsconfig.json'));
|
|
19
15
|
const warnings = [];
|
|
20
16
|
return {
|
|
21
17
|
warnings,
|
|
@@ -29,17 +25,17 @@ export async function getRollupOptions(params) {
|
|
|
29
25
|
polyfills,
|
|
30
26
|
shouldInlineNodeBuiltins: true,
|
|
31
27
|
targetEnvironment: options.targetEnvironment,
|
|
32
|
-
mode:
|
|
28
|
+
mode: context.config.mode,
|
|
33
29
|
}),
|
|
34
30
|
...bundlerOptions.inputOptions,
|
|
35
31
|
// Don't allow overriding the options below
|
|
36
32
|
// Rollup requires entry keys without a leading ./
|
|
37
33
|
input: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\.\//, ''), value])),
|
|
38
34
|
// These are not possible to override properly via JSON config
|
|
39
|
-
plugins:
|
|
35
|
+
plugins: getRollupPlugins({
|
|
40
36
|
isProduction: minify,
|
|
41
37
|
packagePath: inputPath,
|
|
42
|
-
|
|
38
|
+
isTypescript: context.isTypescript,
|
|
43
39
|
dynamicImports,
|
|
44
40
|
sourcemap,
|
|
45
41
|
resolveWebExtensions: !!bundlerCapabilities?.['resolve-web-extensions'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupOptions.js","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,OAAO,
|
|
1
|
+
{"version":3,"file":"getRollupOptions.js","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,wFAAwF;AACxF,mDAAmD;AACnD,MAAM,SAAS,GAAG,IAA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C,cAAc;gBACd,SAAS;gBACT,oBAAoB,EAAE,CAAC,CAAC,mBAAmB,EAAE,CAAC,wBAAwB,CAAC;aACxE,CAAC;YACF,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;gBAClB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;oBAC1E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;SACF;QACD,aAAa,EAAE;YACb,SAAS;YACT,GAAI,cAAc,CAAC,aAA+B;YAClD,8BAA8B;YAC9B,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;YACjF,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,yBAAyB;YACzC,6EAA6E;YAC7E,wEAAwE;YACxE,mFAAmF;YACnF,sBAAsB,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;YAC5D,8DAA8D;YAC9D,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAC;SACxG;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\nimport path from 'path';\nimport type { InputOptions, OutputOptions, RollupLog, RollupOptions } from 'rollup';\nimport { getRollupPlugins } from './getRollupPlugins.js';\n\n// These are the polyfills that we support from the 'rollup-plugin-polyfill-node' plugin\n// that are not included in the node builtins list.\nconst polyfills = new Set(['global', '_inherits', '_buffer_list']);\n\n// Spammy, usually non-actionable warning\nconst ignoredWarnings = ['Circular dependency:'];\n\n/**\n * Converts BundlerOptions to Rollup-specific options.\n */\nexport function getRollupOptions(\n params: {\n options: Omit<BundleOptions, 'entries'>;\n context: BundleContext;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n): {\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n /** Warnings will be pushed to this array (rollup handles warnings with a callback) */\n warnings: RollupLog[];\n} {\n const { options, context, newEntries } = params;\n const {\n inputPath,\n minify,\n external = [],\n inlined = [],\n bundlerOptions = {},\n dynamicImports,\n sourcemap,\n bundlerCapabilities,\n } = options;\n const warnings: RollupLog[] = [];\n\n return {\n warnings,\n inputOptions: {\n external: (id, parent) =>\n shouldExternalizePackage({\n inputPath,\n id,\n parent,\n inlined,\n external,\n polyfills,\n shouldInlineNodeBuiltins: true,\n targetEnvironment: options.targetEnvironment,\n mode: context.config.mode,\n }),\n ...(bundlerOptions.inputOptions as InputOptions),\n // Don't allow overriding the options below\n\n // Rollup requires entry keys without a leading ./\n input: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\\.\\//, ''), value])),\n // These are not possible to override properly via JSON config\n plugins: getRollupPlugins({\n isProduction: minify,\n packagePath: inputPath,\n isTypescript: context.isTypescript,\n dynamicImports,\n sourcemap,\n resolveWebExtensions: !!bundlerCapabilities?.['resolve-web-extensions'],\n }),\n onwarn: (warning) => {\n if (!ignoredWarnings.some((ignored) => warning.message.includes(ignored))) {\n warnings.push(warning);\n }\n },\n },\n outputOptions: {\n sourcemap,\n ...(bundlerOptions.outputOptions as OutputOptions),\n // No overriding these options\n dir: options.outputPath ? path.resolve(inputPath, options.outputPath) : inputPath,\n format: 'es',\n entryFileNames: '[name].js',\n chunkFileNames: '[name].js',\n assetFileNames: 'assets/[name]-[extname]',\n // This is a fix so that the sourcemaps never include the hash in their path,\n // as that invalidates the sourcemap on change and removes break points.\n // ../../../../relative/path/to/src/path/to/file.ts -> rollup://src/path/to/file.ts\n sourcemapPathTransform: (relativeSourcePath, sourcemapPath) =>\n // No need to normalize the path as rollup will do that for us\n 'rollup://' + path.relative(inputPath, path.resolve(path.dirname(sourcemapPath), relativeSourcePath)),\n },\n };\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from 'rollup';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { BundleContext } from '@ms-cloudpack/common-types';
|
|
3
|
+
export declare function getRollupPlugins(options: Pick<BundleContext, 'isTypescript'> & {
|
|
4
|
+
isProduction: boolean | undefined;
|
|
4
5
|
packagePath: string;
|
|
5
|
-
|
|
6
|
-
dynamicImports?: string[];
|
|
6
|
+
dynamicImports: string[] | undefined;
|
|
7
7
|
sourcemap: boolean | undefined;
|
|
8
8
|
resolveWebExtensions: boolean;
|
|
9
|
-
}):
|
|
9
|
+
}): Plugin[];
|
|
10
10
|
//# sourceMappingURL=getRollupPlugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAehE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG;IAC7C,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;CAC/B,GACA,MAAM,EAAE,CAkHV"}
|
package/lib/getRollupPlugins.js
CHANGED
|
@@ -3,12 +3,14 @@ import _dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';
|
|
|
3
3
|
import json from './plugins/json/index.js';
|
|
4
4
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
5
5
|
import _replace from '@rollup/plugin-replace';
|
|
6
|
+
import _swc from '@rollup/plugin-swc';
|
|
6
7
|
import _terser from '@rollup/plugin-terser';
|
|
7
8
|
import _commonjs from '@rollup/plugin-commonjs';
|
|
8
9
|
import _nodePolyfills from 'rollup-plugin-polyfill-node';
|
|
9
10
|
import _postcss from 'rollup-plugin-postcss';
|
|
10
11
|
import { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';
|
|
11
12
|
import { importAsString } from 'rollup-plugin-string-import';
|
|
13
|
+
import { isExternalPackage } from '@ms-cloudpack/path-utilities';
|
|
12
14
|
// Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847
|
|
13
15
|
// (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)
|
|
14
16
|
// At runtime, we should always be using the ESM version of these packages, which use `export default`.
|
|
@@ -19,12 +21,14 @@ const commonjs = _commonjs;
|
|
|
19
21
|
const nodePolyfills = _nodePolyfills;
|
|
20
22
|
const postcss = _postcss;
|
|
21
23
|
const dynamicImportVariables = _dynamicImportVariables;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const swc = _swc;
|
|
25
|
+
export function getRollupPlugins(options) {
|
|
26
|
+
const { isProduction, packagePath, isTypescript, dynamicImports = [], sourcemap, resolveWebExtensions } = options;
|
|
27
|
+
const isExternal = isExternalPackage(packagePath);
|
|
28
|
+
// Only get the SWC config and transform code from internal packages or if there are explicit
|
|
29
|
+
// typescript entries. (This could theoretically miss .jsx files published with a package,
|
|
30
|
+
// but that's unlikely and hasn't been encountered so far.)
|
|
31
|
+
const swcConfigs = !isExternal || isTypescript ? getSwcConfig({ packagePath, sourcemap }) : undefined;
|
|
28
32
|
return [
|
|
29
33
|
// Used to replaces constants in the code.
|
|
30
34
|
replace({
|
|
@@ -82,24 +86,22 @@ export async function getRollupPlugins(options) {
|
|
|
82
86
|
...(resolveWebExtensions ? ['.web.js'] : []),
|
|
83
87
|
'.js',
|
|
84
88
|
'.json',
|
|
85
|
-
...(
|
|
86
|
-
...(
|
|
89
|
+
...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),
|
|
90
|
+
...(!isExternal ? ['.ts', '.tsx'] : []),
|
|
87
91
|
],
|
|
88
92
|
}),
|
|
89
93
|
// Used to browserify node globals (process, global, etc.)
|
|
90
94
|
nodePolyfills(),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(await getSwcPlugin())({
|
|
96
|
-
swc: swcConfigsForTs.tsOnly,
|
|
97
|
-
include: /\.ts$/,
|
|
95
|
+
swcConfigs &&
|
|
96
|
+
swc({
|
|
97
|
+
include: /\.[cm]?tsx?$/,
|
|
98
|
+
swc: swcConfigs.tsx,
|
|
98
99
|
}),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
include: /\.
|
|
100
|
+
// Support .jsx
|
|
101
|
+
swcConfigs &&
|
|
102
|
+
swc({
|
|
103
|
+
include: /\.[cm]?jsx$/,
|
|
104
|
+
swc: swcConfigs.jsx,
|
|
103
105
|
}),
|
|
104
106
|
// Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra
|
|
105
107
|
// parsing/processing step on all files.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA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AC,CAAC;aACxF;SACF,CAAC;QAEF,2CAA2C;QAC3C,CAAC,CAAC,YAAY,IAAI,MAAM,EAAE;QAE1B,cAAc,CAAC;YACb,OAAO,EAAE,WAAW;SACrB,CAAC;KACH,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { getSwcConfig } from '@ms-cloudpack/bundler-utilities';\nimport _dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';\nimport json from './plugins/json/index.js';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport _replace from '@rollup/plugin-replace';\nimport _swc from '@rollup/plugin-swc';\nimport _terser from '@rollup/plugin-terser';\nimport _commonjs from '@rollup/plugin-commonjs';\nimport type { Plugin } from 'rollup';\nimport _nodePolyfills from 'rollup-plugin-polyfill-node';\nimport _postcss, { type PostCSSPluginConf } from 'rollup-plugin-postcss';\nimport { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';\nimport { importAsString } from 'rollup-plugin-string-import';\nimport type { BundleContext } from '@ms-cloudpack/common-types';\nimport { isExternalPackage } from '@ms-cloudpack/path-utilities';\n\n// Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847\n// (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)\n// At runtime, we should always be using the ESM version of these packages, which use `export default`.\n// However, typescript interprets the types as CJS modules with a `default` property (which will fail at runtime).\nconst replace = _replace as unknown as typeof _replace.default;\nconst terser = _terser as unknown as typeof _terser.default;\nconst commonjs = _commonjs as unknown as typeof _commonjs.default;\nconst nodePolyfills = _nodePolyfills as unknown as typeof _nodePolyfills.default;\nconst postcss = _postcss as unknown as typeof _postcss.default;\nconst dynamicImportVariables = _dynamicImportVariables as unknown as typeof _dynamicImportVariables.default;\nconst swc = _swc as unknown as typeof _swc.default;\n\nexport function getRollupPlugins(\n options: Pick<BundleContext, 'isTypescript'> & {\n isProduction: boolean | undefined;\n packagePath: string;\n dynamicImports: string[] | undefined;\n sourcemap: boolean | undefined;\n resolveWebExtensions: boolean;\n },\n): Plugin[] {\n const { isProduction, packagePath, isTypescript, dynamicImports = [], sourcemap, resolveWebExtensions } = options;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code from internal packages or if there are explicit\n // typescript entries. (This could theoretically miss .jsx files published with a package,\n // but that's unlikely and hasn't been encountered so far.)\n const swcConfigs = !isExternal || isTypescript ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n return [\n // Used to replaces constants in the code.\n replace({\n values: {\n 'process.env.NODE_ENV': isProduction ? `\"production\"` : `\"development\"`,\n DEPRECATED_UNIT_TEST: 'true',\n },\n preventAssignment: true,\n }),\n\n normalizeRequireStatements(),\n\n postcss({\n // Use named exports in addition to the default export.\n namedExports: true,\n // Respect the `modules` option regardless of the file extension.\n // Otherwise only *.module.* will be passed through postcss-modules and exports won't work correctly.\n autoModules: false,\n // Options for `postcss-modules` plugin. Note that as of writing, rollup-plugin-postcss\n // uses version 4: https://github.com/madyankin/postcss-modules/tree/v4.3.1\n modules: {\n // Treat .css and .s[ac]ss files as global stylesheets unless they have the `.module` suffix\n globalModulePaths: [/(?<!\\.module)\\.(css|s[ac]ss)$/],\n // Export global classnames in addition to local ones\n exportGlobals: true,\n // Convert non-identifier-friendly class names to exported camelCase identifiers (like css-loader),\n // but keep the original names to use in the default export object too\n localsConvention: 'camelCase',\n },\n // don't load postcss config\n config: false,\n minimize: isProduction,\n sourceMap: sourcemap,\n // spammy, non-actionable warning (types have incorrect extra required props)\n use: { sass: { silenceDeprecations: ['legacy-js-api'] } } as PostCSSPluginConf['use'],\n }),\n\n // Used to parse commonjs.\n commonjs({\n // Treat all dependencies as external esm modules (since we'll be bundling them.)\n esmExternals: true,\n\n // When __esModule is true, the default export is `exports.default`; otherwise it's `module.exports`.\n defaultIsModuleExports: true,\n\n // Convert `require('library')` to `import * as library from 'library'` always, because `import library from\n // 'library' risks runtime failure if the dependency is ESM that doesn't export a default.\n requireReturnsDefault: false,\n }),\n\n // Used to compile json files into javascript exports.\n json({\n extensions: ['.json', '.resjson'],\n }),\n\n // // Used to resolve node_modules.\n nodeResolve({\n preferBuiltins: false,\n browser: true,\n // TODO: Align with other bundlers https://github.com/microsoft/cloudpack/issues/2687\n extensions: [\n ...(resolveWebExtensions ? ['.web.js'] : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),\n ...(!isExternal ? ['.ts', '.tsx'] : []),\n ],\n }),\n\n // Used to browserify node globals (process, global, etc.)\n nodePolyfills(),\n\n swcConfigs &&\n swc({\n include: /\\.[cm]?tsx?$/,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: /\\.[cm]?jsx$/,\n swc: swcConfigs.jsx,\n }),\n\n // Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra\n // parsing/processing step on all files.\n // Must be done AFTER the TS step because it can only handle JS syntax.\n dynamicImportVariables({\n include: [\n '**/*.dynamic.*',\n // Convert the dynamic imports options to globs starting with **\n // (the plugin seems to be matching against full paths)\n ...dynamicImports.map((d) => (d.startsWith('**/') ? d : d.replace(/^(\\.?\\/)?/, '**/'))),\n ],\n }),\n\n // Minify production builds as a last step.\n !!isProduction && terser(),\n\n importAsString({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
|
package/lib/rollup.js
CHANGED
|
@@ -15,7 +15,7 @@ export const rollup = {
|
|
|
15
15
|
if (errors?.length) {
|
|
16
16
|
return { errors };
|
|
17
17
|
}
|
|
18
|
-
const { warnings, ...baseConfig } =
|
|
18
|
+
const { warnings, ...baseConfig } = getRollupOptions({ options, context, newEntries });
|
|
19
19
|
const bundlerCapabilitiesOptions = {
|
|
20
20
|
'asset-inline': { extensions: base64AssetExtensions },
|
|
21
21
|
...(options.bundlerCapabilities || {}),
|
package/lib/rollup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAuC,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAY;IAC7B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK,WAAW,OAAO,EAAE,OAAO;QACtC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAuC,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,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YAC3C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,iGAAiG;YACjG,MAAM,KAAK,GAAG,CAAgB,CAAC;YAC/B,MAAM,YAAY,GAAkB;gBAClC,IAAI,EAAE,KAAK,CAAC,OAAO;gBACnB,oCAAoC;gBACpC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBACzG,MAAM,EAAE,QAAQ;aACjB,CAAC;YAEF,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;gBAChC,YAAY,CAAC,QAAQ,GAAG,kBAAkB,CAAC;oBACzC,2CAA2C;oBAC3C,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,sCAAsC;oBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;oBACZ,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC7B,CAAC,CAAC;YACL,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QACpC,CAAC;QAED,OAAO,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;CACF,CAAC","sourcesContent":["import type { BundleMessage, Bundler, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { writeESMStubsInWorker } from '@ms-cloudpack/esm-stub-utilities';\nimport { rollup as runRollup, type RollupError, type RollupOutput, VERSION } from 'rollup';\nimport { getRollupOptions } from './getRollupOptions.js';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\nimport { normalizeRollupOutput } from './normalizeRollupOutput.js';\nimport { rollupCapabilities } from './rollupCapabilities.js';\nimport { base64AssetExtensions } from '@ms-cloudpack/bundler-utilities';\n\nconst bundlerName = 'rollup';\n\nexport const rollup: Bundler = {\n name: bundlerName,\n version: VERSION,\n bundle: async function (options, context) {\n const { newEntries, errors } = await writeESMStubsInWorker(options);\n if (errors?.length) {\n return { errors };\n }\n\n const { warnings, ...baseConfig } = getRollupOptions({ options, context, newEntries });\n\n const bundlerCapabilitiesOptions: BundlerCapabilitiesOptions = {\n 'asset-inline': { extensions: base64AssetExtensions },\n ...(options.bundlerCapabilities || {}),\n };\n\n const { inputOptions, outputOptions } = await processCapabilities({\n bundlerName,\n baseConfig,\n bundlerCapabilitiesOptions,\n internalCapabilities: rollupCapabilities,\n bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,\n });\n\n let output: RollupOutput;\n\n try {\n const result = await runRollup(inputOptions);\n output = await result.write(outputOptions);\n await result.close();\n } catch (e) {\n // This might only be a regular Error, but the extra RollupError properties accessed are optional\n const error = e as RollupError;\n const errorMessage: BundleMessage = {\n text: error.message,\n // remove the message from the stack\n notes: [{ text: error.stack?.includes(error.message) ? error.stack.split(error.message)[1].trim() : '' }],\n source: 'rollup',\n };\n\n if (error.id || error.loc?.file) {\n errorMessage.location = normalizeRollupLoc({\n // contains line, column, and possibly file\n loc: error.loc,\n // some errors only have the file here\n id: error.id,\n inputPath: options.inputPath,\n });\n }\n\n return { errors: [errorMessage] };\n }\n\n return normalizeRollupOutput({ options, inputOptions, outputOptions, output, warnings });\n },\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler-rollup",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "A cloudpack plugin for abstracting rollup.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-capabilities": "^0.2.
|
|
18
|
-
"@ms-cloudpack/bundler-utilities": "^0.
|
|
19
|
-
"@ms-cloudpack/common-types": "^0.26.
|
|
20
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.15.
|
|
21
|
-
"@ms-cloudpack/package-utilities": "^12.3.
|
|
17
|
+
"@ms-cloudpack/bundler-capabilities": "^0.2.34",
|
|
18
|
+
"@ms-cloudpack/bundler-utilities": "^0.5.1",
|
|
19
|
+
"@ms-cloudpack/common-types": "^0.26.4",
|
|
20
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.15.7",
|
|
21
|
+
"@ms-cloudpack/package-utilities": "^12.3.20",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
23
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
23
|
+
"@ms-cloudpack/path-utilities": "^3.1.14",
|
|
24
24
|
"@rollup/plugin-commonjs": "^28.0.4",
|
|
25
25
|
"@rollup/plugin-dynamic-import-vars": "^2.0.0",
|
|
26
26
|
"@rollup/plugin-node-resolve": "^16.0.0",
|