@ms-cloudpack/bundler-rollup 0.6.5 → 0.6.6

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;AAyBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CA0K1G"}
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;AAyBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CA4K1G"}
@@ -31,7 +31,9 @@ export function getRollupPlugins(options, context) {
31
31
  const { resolve } = context.config;
32
32
  const isExternal = isExternalPackage(packagePath);
33
33
  // Only get the SWC config and transform code if needed
34
- const swcConfigs = context.requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;
34
+ const swcConfigs = context.requiresTranspile
35
+ ? getSwcConfig({ packagePath, sourcemap, reactRefresh: options.hmr })
36
+ : undefined;
35
37
  // Add relay plugin to SWC configs if enabled
36
38
  if (swcConfigs && relay) {
37
39
  // Ensure options is always an object before spreading
@@ -1 +1 @@
1
- {"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],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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 {\n isExternalPackage,\n resolveModule,\n jsxRegex,\n typescriptRegex,\n webExtensions,\n} 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 inputCwd: packagePath,\n // In addition to this package context, attempt resolving dependencies from the app path.\n // This could potentially be updated in the future to fully respect `resolve.modules`, but it\n // appears that setting is currently only used for runtime (not build) dependency resolution.\n resolveCwd: context.config.appPath,\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 // Disable this warning from sass for now.\n // TODO: since we forked the plugin, we could fix this if we clarify our required sass version or maybe support both\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 ? webExtensions.filter((ext) => ext.includes('j')) : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? webExtensions.filter((ext) => !ext.includes('j')) : []),\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: typescriptRegex,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: jsxRegex,\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,MAA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AC,CAAC,IAAI,SAAS;SAC9E,CAAC;QAEF,0DAA0D;QAC1D,aAAa,EAAE;QAEf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,eAAe;gBACxB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,eAAe;QACf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,QAAQ;gBACjB,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 {\n isExternalPackage,\n resolveModule,\n jsxRegex,\n typescriptRegex,\n webExtensions,\n} 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\n ? getSwcConfig({ packagePath, sourcemap, reactRefresh: options.hmr })\n : 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 inputCwd: packagePath,\n // In addition to this package context, attempt resolving dependencies from the app path.\n // This could potentially be updated in the future to fully respect `resolve.modules`, but it\n // appears that setting is currently only used for runtime (not build) dependency resolution.\n resolveCwd: context.config.appPath,\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 // Disable this warning from sass for now.\n // TODO: since we forked the plugin, we could fix this if we clarify our required sass version or maybe support both\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 ? webExtensions.filter((ext) => ext.includes('j')) : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? webExtensions.filter((ext) => !ext.includes('j')) : []),\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: typescriptRegex,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: jsxRegex,\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.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Cloudpack's wrapper for the Rollup bundler",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,14 +25,14 @@
25
25
  "prepack": "cp .npmignore lib/.npmignore"
26
26
  },
27
27
  "dependencies": {
28
- "@ms-cloudpack/bundler-capabilities": "^0.5.0",
29
- "@ms-cloudpack/bundler-utilities": "^0.8.0",
30
- "@ms-cloudpack/common-types": "^0.33.1",
31
- "@ms-cloudpack/common-types-browser": "^0.6.4",
32
- "@ms-cloudpack/esm-stub-utilities": "^0.15.35",
33
- "@ms-cloudpack/package-utilities": "^13.2.5",
34
- "@ms-cloudpack/path-string-parsing": "^1.2.7",
35
- "@ms-cloudpack/path-utilities": "^3.2.2",
28
+ "@ms-cloudpack/bundler-capabilities": "^0.5.1",
29
+ "@ms-cloudpack/bundler-utilities": "^0.9.0",
30
+ "@ms-cloudpack/common-types": "^0.33.2",
31
+ "@ms-cloudpack/common-types-browser": "^0.6.5",
32
+ "@ms-cloudpack/esm-stub-utilities": "^0.15.36",
33
+ "@ms-cloudpack/package-utilities": "^13.2.6",
34
+ "@ms-cloudpack/path-string-parsing": "^1.3.0",
35
+ "@ms-cloudpack/path-utilities": "^3.2.3",
36
36
  "@rollup/plugin-alias": "^5.0.1",
37
37
  "@rollup/plugin-commonjs": "^29.0.0",
38
38
  "@rollup/plugin-dynamic-import-vars": "^2.0.0",