@ms-cloudpack/bundler-rollup 0.4.13 → 0.4.15
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
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
1
|
# @ms-cloudpack/bundler-rollup
|
|
2
2
|
|
|
3
|
-
Provides a Cloudpack bundler abstraction around the Rollup bundler.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
### `async function bundlePackage(options)`
|
|
8
|
-
|
|
9
|
-
```tsx
|
|
10
|
-
import { bundlePackage } from '@ms-cloudpack/bundler';
|
|
11
|
-
|
|
12
|
-
async function start() {
|
|
13
|
-
const result = await bundlePackage({
|
|
14
|
-
packagePath: process.cwd(),
|
|
15
|
-
outputPath: path.join(process.cwd(), 'dist'),
|
|
16
|
-
outputType: 'library',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
console.log(result);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
start();
|
|
23
|
-
```
|
|
3
|
+
Provides a Cloudpack bundler abstraction around the [Rollup](https://rollupjs.org/) bundler.
|
package/lib/getRollupOptions.js
CHANGED
|
@@ -35,7 +35,7 @@ export function getRollupOptions(params) {
|
|
|
35
35
|
plugins: getRollupPlugins({
|
|
36
36
|
isProduction: minify,
|
|
37
37
|
packagePath: inputPath,
|
|
38
|
-
|
|
38
|
+
requiresTranspile: context.requiresTranspile,
|
|
39
39
|
dynamicImports,
|
|
40
40
|
sourcemap,
|
|
41
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,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAA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Aa,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 requiresTranspile: context.requiresTranspile,\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,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from 'rollup';
|
|
2
2
|
import type { BundleContext } from '@ms-cloudpack/common-types';
|
|
3
|
-
export declare function getRollupPlugins(options: Pick<BundleContext, '
|
|
3
|
+
export declare function getRollupPlugins(options: Pick<BundleContext, 'requiresTranspile'> & {
|
|
4
4
|
isProduction: boolean | undefined;
|
|
5
5
|
packagePath: string;
|
|
6
6
|
dynamicImports: string[] | undefined;
|
|
@@ -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;AAKrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAchE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,
|
|
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;AAchE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAAG;IAClD,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,CAwHV"}
|
package/lib/getRollupPlugins.js
CHANGED
|
@@ -22,12 +22,11 @@ const nodePolyfills = _nodePolyfills;
|
|
|
22
22
|
const dynamicImportVariables = _dynamicImportVariables;
|
|
23
23
|
const swc = _swc;
|
|
24
24
|
export function getRollupPlugins(options) {
|
|
25
|
-
const { isProduction, packagePath,
|
|
25
|
+
const { isProduction, packagePath, requiresTranspile, dynamicImports = [], sourcemap, resolveWebExtensions, } = options;
|
|
26
26
|
const isExternal = isExternalPackage(packagePath);
|
|
27
|
-
// Only get the SWC config and transform code from internal packages or if there are explicit
|
|
28
|
-
// typescript
|
|
29
|
-
|
|
30
|
-
const swcConfigs = !isExternal || isTypescript ? getSwcConfig({ packagePath, sourcemap }) : undefined;
|
|
27
|
+
// Only get the SWC config and transform code from internal packages, or if there are explicit
|
|
28
|
+
// typescript or jsx entries
|
|
29
|
+
const swcConfigs = !isExternal || requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;
|
|
31
30
|
return [
|
|
32
31
|
// Used to replaces constants in the code.
|
|
33
32
|
replace({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAA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C,EAAE,CAAC;aACxC;SACF,CAAC;QAEF,0DAA0D;QAC1D,aAAa,EAAE;QAEf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,cAAc;gBACvB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,eAAe;QACf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,aAAa;gBACtB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,4FAA4F;QAC5F,wCAAwC;QACxC,uEAAuE;QACvE,sBAAsB,CAAC;YACrB,OAAO,EAAE;gBACP,gBAAgB;gBAChB,gEAAgE;gBAChE,uDAAuD;gBACvD,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,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 from './plugins/postcss/index.js';\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 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, 'requiresTranspile'> & {\n isProduction: boolean | undefined;\n packagePath: string;\n dynamicImports: string[] | undefined;\n sourcemap: boolean | undefined;\n resolveWebExtensions: boolean;\n },\n): Plugin[] {\n const {\n isProduction,\n packagePath,\n requiresTranspile,\n dynamicImports = [],\n sourcemap,\n resolveWebExtensions,\n } = 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 or jsx entries\n const swcConfigs = !isExternal || requiresTranspile ? 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'] } },\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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler-rollup",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.15",
|
|
4
|
+
"description": "Cloudpack's wrapper for the Rollup bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-capabilities": "^0.3.
|
|
18
|
-
"@ms-cloudpack/bundler-utilities": "^0.5.
|
|
19
|
-
"@ms-cloudpack/common-types": "^0.
|
|
20
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.15.
|
|
21
|
-
"@ms-cloudpack/package-utilities": "^12.5.
|
|
17
|
+
"@ms-cloudpack/bundler-capabilities": "^0.3.3",
|
|
18
|
+
"@ms-cloudpack/bundler-utilities": "^0.5.10",
|
|
19
|
+
"@ms-cloudpack/common-types": "^0.28.0",
|
|
20
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.15.16",
|
|
21
|
+
"@ms-cloudpack/package-utilities": "^12.5.2",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
23
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
23
|
+
"@ms-cloudpack/path-utilities": "^3.1.23",
|
|
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",
|