@ms-cloudpack/bundler-rollup 0.5.5 → 0.6.1

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.
@@ -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;AAIrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAsC,MAAM,4BAA4B,CAAC;AAmBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAsK1G"}
1
+ {"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAsC,MAAM,4BAA4B,CAAC;AAmBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAoK1G"}
@@ -30,9 +30,8 @@ export function getRollupPlugins(options, context) {
30
30
  const { relay, 'resolve-web-extensions': resolveWebExtensions } = bundlerCapabilities;
31
31
  const { resolve } = context.config;
32
32
  const isExternal = isExternalPackage(packagePath);
33
- // Only get the SWC config and transform code from internal packages, or if there are explicit
34
- // typescript or jsx entries
35
- const swcConfigs = !isExternal || context.requiresTranspile || relay ? getSwcConfig({ packagePath, sourcemap }) : undefined;
33
+ // Only get the SWC config and transform code if needed
34
+ const swcConfigs = context.requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;
36
35
  // Add relay plugin to SWC configs if enabled
37
36
  if (swcConfigs && relay) {
38
37
  // Ensure options is always an object before spreading
@@ -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,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AACzE,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAEhD,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,8FAA8F;AAC9F,6EAA6E;AAC7E,uGAAuG;AACvG,kHAAkH;AAClH,MAAM,OAAO,GAAG,QAA8C,CAAC;AAC/D,MAAM,MAAM,GAAG,OAA4C,CAAC;AAC5D,MAAM,QAAQ,GAAG,SAAgD,CAAC;AAClE,MAAM,aAAa,GAAG,cAA0D,CAAC;AACjF,MAAM,sBAAsB,GAAG,uBAA4E,CAAC;AAC5G,MAAM,GAAG,GAAG,IAAsC,CAAC;AACnD,MAAM,KAAK,GAAG,WAAoD,CAAC;AAEnE,MAAM,UAAU,gBAAgB,CAAC,OAAuC,EAAE,OAAsB;IAC9F,MAAM,EACJ,MAAM,EAAE,YAAY,EACpB,SA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,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;YAC3F,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS;SAC9E,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,YAAY,CAAC;YACX,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 type { BundleContext, BundleOptions, InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport aliasPlugin from '@rollup/plugin-alias';\nimport stringImport from './plugins/stringImport.js';\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;\nconst alias = aliasPlugin as unknown as typeof aliasPlugin.default;\n\nexport function getRollupPlugins(options: Omit<BundleOptions, 'entries'>, context: BundleContext): Plugin[] {\n const {\n minify: isProduction,\n inputPath: packagePath,\n dynamicImports = [],\n sourcemap,\n dedupeAliases,\n bundlerCapabilities = {},\n } = options;\n const { relay, 'resolve-web-extensions': resolveWebExtensions } =\n bundlerCapabilities as InternalBundlerCapabilitiesOptions;\n const { resolve } = context.config;\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 =\n !isExternal || context.requiresTranspile || relay ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n // Add relay plugin to SWC configs if enabled\n if (swcConfigs && relay) {\n // Ensure options is always an object before spreading\n const safeOptions: Partial<typeof relay> = relay && typeof relay === 'object' ? relay : {};\n\n if (!safeOptions.rootDir) {\n throw new Error('The relay capability requires a rootDir option to be set.');\n }\n\n // Base plugin options. \"eagerEsModules\" needs to be set or bundlers may default to \"require\" instead of inlining\n const relayPluginOptions = { eagerEsModules: true, ...safeOptions, language: 'typescript' };\n\n console.debug('Relay plugin options:', JSON.stringify(relayPluginOptions, null, 2));\n\n const relayPlugin = fileURLToPath(\n resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl: import.meta.url }),\n );\n\n // Add relay plugin to tsx config\n swcConfigs.tsx.jsc ??= {};\n swcConfigs.tsx.jsc.experimental ??= {};\n swcConfigs.tsx.jsc.experimental.plugins ??= [];\n swcConfigs.tsx.jsc.experimental.plugins.push([relayPlugin, relayPluginOptions]);\n\n // Add relay plugin to jsx config with JavaScript language\n swcConfigs.jsx.jsc ??= {};\n swcConfigs.jsx.jsc.experimental ??= {};\n swcConfigs.jsx.jsc.experimental.plugins ??= [];\n swcConfigs.jsx.jsc.experimental.plugins.push([relayPlugin, { ...relayPluginOptions, language: 'javascript' }]);\n }\n\n return [\n // Dedupe alias plugin to redirect imports to app's version\n dedupeAliases &&\n alias({\n entries: Object.entries(dedupeAliases).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n }),\n\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 moduleDirectories: resolve?.modules?.filter((m) => !path.isAbsolute(m)) ?? ['node_modules'],\n modulePaths: resolve?.modules?.filter((m) => path.isAbsolute(m)) ?? undefined,\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 stringImport({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
1
+ {"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AACzE,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAEhD,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,8FAA8F;AAC9F,6EAA6E;AAC7E,uGAAuG;AACvG,kHAAkH;AAClH,MAAM,OAAO,GAAG,QAA8C,CAAC;AAC/D,MAAM,MA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AAY,CAAC;YACX,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 type { BundleContext, BundleOptions, InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport aliasPlugin from '@rollup/plugin-alias';\nimport stringImport from './plugins/stringImport.js';\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;\nconst alias = aliasPlugin as unknown as typeof aliasPlugin.default;\n\nexport function getRollupPlugins(options: Omit<BundleOptions, 'entries'>, context: BundleContext): Plugin[] {\n const {\n minify: isProduction,\n inputPath: packagePath,\n dynamicImports = [],\n sourcemap,\n dedupeAliases,\n bundlerCapabilities = {},\n } = options;\n const { relay, 'resolve-web-extensions': resolveWebExtensions } =\n bundlerCapabilities as InternalBundlerCapabilitiesOptions;\n const { resolve } = context.config;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code if needed\n const swcConfigs = context.requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n // Add relay plugin to SWC configs if enabled\n if (swcConfigs && relay) {\n // Ensure options is always an object before spreading\n const safeOptions: Partial<typeof relay> = relay && typeof relay === 'object' ? relay : {};\n\n if (!safeOptions.rootDir) {\n throw new Error('The relay capability requires a rootDir option to be set.');\n }\n\n // Base plugin options. \"eagerEsModules\" needs to be set or bundlers may default to \"require\" instead of inlining\n const relayPluginOptions = { eagerEsModules: true, ...safeOptions, language: 'typescript' };\n\n console.debug('Relay plugin options:', JSON.stringify(relayPluginOptions, null, 2));\n\n const relayPlugin = fileURLToPath(\n resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl: import.meta.url }),\n );\n\n // Add relay plugin to tsx config\n swcConfigs.tsx.jsc ??= {};\n swcConfigs.tsx.jsc.experimental ??= {};\n swcConfigs.tsx.jsc.experimental.plugins ??= [];\n swcConfigs.tsx.jsc.experimental.plugins.push([relayPlugin, relayPluginOptions]);\n\n // Add relay plugin to jsx config with JavaScript language\n swcConfigs.jsx.jsc ??= {};\n swcConfigs.jsx.jsc.experimental ??= {};\n swcConfigs.jsx.jsc.experimental.plugins ??= [];\n swcConfigs.jsx.jsc.experimental.plugins.push([relayPlugin, { ...relayPluginOptions, language: 'javascript' }]);\n }\n\n return [\n // Dedupe alias plugin to redirect imports to app's version\n dedupeAliases &&\n alias({\n entries: Object.entries(dedupeAliases).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n }),\n\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 moduleDirectories: resolve?.modules?.filter((m) => !path.isAbsolute(m)) ?? ['node_modules'],\n modulePaths: resolve?.modules?.filter((m) => path.isAbsolute(m)) ?? undefined,\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 stringImport({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-rollup",
3
- "version": "0.5.5",
3
+ "version": "0.6.1",
4
4
  "description": "Cloudpack's wrapper for the Rollup bundler",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@ms-cloudpack/bundler-capabilities": "^0.4.8",
29
- "@ms-cloudpack/bundler-utilities": "^0.7.3",
29
+ "@ms-cloudpack/bundler-utilities": "^0.7.5",
30
30
  "@ms-cloudpack/common-types": "^0.33.0",
31
- "@ms-cloudpack/esm-stub-utilities": "^0.15.33",
32
- "@ms-cloudpack/package-utilities": "^13.2.3",
31
+ "@ms-cloudpack/esm-stub-utilities": "^0.15.34",
32
+ "@ms-cloudpack/package-utilities": "^13.2.4",
33
33
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
34
- "@ms-cloudpack/path-utilities": "^3.2.0",
34
+ "@ms-cloudpack/path-utilities": "^3.2.1",
35
35
  "@rollup/plugin-alias": "^5.0.1",
36
36
  "@rollup/plugin-commonjs": "^28.0.4",
37
37
  "@rollup/plugin-dynamic-import-vars": "^2.0.0",