@ms-cloudpack/bundler-rollup 0.6.3 → 0.6.5

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.
Files changed (43) hide show
  1. package/NOTICE.txt +61 -0
  2. package/lib/getRollupPlugins.d.ts.map +1 -1
  3. package/lib/getRollupPlugins.js +7 -1
  4. package/lib/getRollupPlugins.js.map +1 -1
  5. package/lib/plugins/json/index.js +1 -1
  6. package/lib/plugins/json/index.js.map +1 -1
  7. package/lib/plugins/postcss/index.d.ts +3 -10
  8. package/lib/plugins/postcss/index.d.ts.map +1 -1
  9. package/lib/plugins/postcss/index.js +37 -48
  10. package/lib/plugins/postcss/index.js.map +1 -1
  11. package/lib/plugins/postcss/less-loader.d.ts +2 -8
  12. package/lib/plugins/postcss/less-loader.d.ts.map +1 -1
  13. package/lib/plugins/postcss/less-loader.js +8 -11
  14. package/lib/plugins/postcss/less-loader.js.map +1 -1
  15. package/lib/plugins/postcss/loaders.d.ts +15 -21
  16. package/lib/plugins/postcss/loaders.d.ts.map +1 -1
  17. package/lib/plugins/postcss/loaders.js +14 -34
  18. package/lib/plugins/postcss/loaders.js.map +1 -1
  19. package/lib/plugins/postcss/postcss-loader.d.ts +2 -9
  20. package/lib/plugins/postcss/postcss-loader.d.ts.map +1 -1
  21. package/lib/plugins/postcss/postcss-loader.js +30 -36
  22. package/lib/plugins/postcss/postcss-loader.js.map +1 -1
  23. package/lib/plugins/postcss/sass-loader.d.ts +5 -8
  24. package/lib/plugins/postcss/sass-loader.d.ts.map +1 -1
  25. package/lib/plugins/postcss/sass-loader.js +50 -52
  26. package/lib/plugins/postcss/sass-loader.js.map +1 -1
  27. package/lib/plugins/postcss/types.d.ts +96 -25
  28. package/lib/plugins/postcss/types.d.ts.map +1 -1
  29. package/lib/plugins/postcss/types.js +0 -1
  30. package/lib/plugins/postcss/types.js.map +1 -1
  31. package/lib/plugins/postcss/utils/load-module.d.ts +10 -4
  32. package/lib/plugins/postcss/utils/load-module.d.ts.map +1 -1
  33. package/lib/plugins/postcss/utils/load-module.js +10 -11
  34. package/lib/plugins/postcss/utils/load-module.js.map +1 -1
  35. package/lib/plugins/postcss/utils/normalize-path.d.ts +7 -2
  36. package/lib/plugins/postcss/utils/normalize-path.d.ts.map +1 -1
  37. package/lib/plugins/postcss/utils/normalize-path.js +12 -3
  38. package/lib/plugins/postcss/utils/normalize-path.js.map +1 -1
  39. package/package.json +5 -4
  40. package/lib/plugins/postcss/utils/humanlize-path.d.ts +0 -3
  41. package/lib/plugins/postcss/utils/humanlize-path.d.ts.map +0 -1
  42. package/lib/plugins/postcss/utils/humanlize-path.js +0 -7
  43. package/lib/plugins/postcss/utils/humanlize-path.js.map +0 -1
package/NOTICE.txt ADDED
@@ -0,0 +1,61 @@
1
+ NOTICES
2
+
3
+ This package incorporates material as listed below or described in the code.
4
+
5
+ ---
6
+
7
+ @rollup/plugin-json 6.1.0 - MIT
8
+ https://github.com/rollup/plugins/tree/master/packages/json#readme
9
+
10
+ Author: rollup
11
+
12
+ The MIT License (MIT)
13
+
14
+ Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in
24
+ all copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
+ THE SOFTWARE.
33
+
34
+ ---
35
+
36
+ rollup-plugin-postcss 3.0.0 - MIT
37
+ https://github.com/egoist/rollup-plugin-postcss
38
+
39
+ Author: EGOIST <0x142857@gmail.com>
40
+
41
+ The MIT License (MIT)
42
+
43
+ Copyright (c) 2017 EGOIST <0x142857@gmail.com>
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining a copy
46
+ of this software and associated documentation files (the "Software"), to deal
47
+ in the Software without restriction, including without limitation the rights
48
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
+ copies of the Software, and to permit persons to whom the Software is
50
+ furnished to do so, subject to the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be included in
53
+ all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61
+ THE SOFTWARE.
@@ -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,CAoK1G"}
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"}
@@ -73,6 +73,11 @@ export function getRollupPlugins(options, context) {
73
73
  }),
74
74
  normalizeRequireStatements(),
75
75
  postcss({
76
+ inputCwd: packagePath,
77
+ // In addition to this package context, attempt resolving dependencies from the app path.
78
+ // This could potentially be updated in the future to fully respect `resolve.modules`, but it
79
+ // appears that setting is currently only used for runtime (not build) dependency resolution.
80
+ resolveCwd: context.config.appPath,
76
81
  // Use named exports in addition to the default export.
77
82
  namedExports: true,
78
83
  // Respect the `modules` option regardless of the file extension.
@@ -93,7 +98,8 @@ export function getRollupPlugins(options, context) {
93
98
  config: false,
94
99
  minimize: isProduction,
95
100
  sourceMap: sourcemap,
96
- // spammy, non-actionable warning (types have incorrect extra required props)
101
+ // Disable this warning from sass for now.
102
+ // TODO: since we forked the plugin, we could fix this if we clarify our required sass version or maybe support both
97
103
  use: { sass: { silenceDeprecations: ['legacy-js-api'] } },
98
104
  }),
99
105
  // Used to parse commonjs.
@@ -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,C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E,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,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 ? 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 ? 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,MAAM,yCAAyC,CAAC;AAErF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,eAAe,EACf,aAAa,GACd,MAAM,8BAA8B,CAAC;AACtC,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,OAA4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C,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 ? 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,4 +1,4 @@
1
- // Fork of @rollup/json to be able to define custom extensions such as resjson.
1
+ // Fork of @rollup/plugin-json v6.1.0 to be able to define custom extensions such as resjson.
2
2
  // TODO: Remove this fork when this PR is merged and released: https://github.com/rollup/plugins/pull/1857
3
3
  /* tsl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AqB;wBACpD,MAAM;qBACP,CAAC;oBACF,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;iBACtB,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,OAAO,GAAG,2BAA2B,CAAC;gBAC5C,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;gBACxC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @rollup/json to be able to define custom extensions such as resjson.\n// TODO: Remove this fork when this PR is merged and released: https://github.com/rollup/plugins/pull/1857\n/* tslint:disable */\n/* eslint-disable */\n// @ts-nocheck\nimport { createFilter, dataToEsm } from '@rollup/pluginutils';\nimport { extname } from 'path';\n\nexport default function json(options = {}) {\n const filter = createFilter(options.include, options.exclude);\n const indent = 'indent' in options ? options.indent : '\\t';\n const extensions = new Set('extensions' in options ? options.extensions : ['.json']);\n\n return {\n name: 'json',\n\n transform(code, id) {\n const extension = extname(id);\n\n if (!extensions.has(extension) || !filter(id)) return null;\n\n try {\n const parsed = JSON.parse(code);\n return {\n code: dataToEsm(parsed, {\n preferConst: options.preferConst,\n compact: options.compact,\n namedExports: options.namedExports,\n includeArbitraryNames: options.includeArbitraryNames,\n indent,\n }),\n map: { mappings: '' },\n };\n } catch (err) {\n const message = 'Could not parse JSON file';\n this.error({ message, id, cause: err });\n return null;\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/json/index.js"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,0GAA0G;AAC1G,oBAAoB;AACpB,oBAAoB;AACpB,cAAc;AACd,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,I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CAAC;AACJ,CAAC","sourcesContent":["// Fork of @rollup/plugin-json v6.1.0 to be able to define custom extensions such as resjson.\n// TODO: Remove this fork when this PR is merged and released: https://github.com/rollup/plugins/pull/1857\n/* tslint:disable */\n/* eslint-disable */\n// @ts-nocheck\nimport { createFilter, dataToEsm } from '@rollup/pluginutils';\nimport { extname } from 'path';\n\nexport default function json(options = {}) {\n const filter = createFilter(options.include, options.exclude);\n const indent = 'indent' in options ? options.indent : '\\t';\n const extensions = new Set('extensions' in options ? options.extensions : ['.json']);\n\n return {\n name: 'json',\n\n transform(code, id) {\n const extension = extname(id);\n\n if (!extensions.has(extension) || !filter(id)) return null;\n\n try {\n const parsed = JSON.parse(code);\n return {\n code: dataToEsm(parsed, {\n preferConst: options.preferConst,\n compact: options.compact,\n namedExports: options.namedExports,\n includeArbitraryNames: options.includeArbitraryNames,\n indent,\n }),\n map: { mappings: '' },\n };\n } catch (err) {\n const message = 'Could not parse JSON file';\n this.error({ message, id, cause: err });\n return null;\n }\n },\n };\n}\n"]}
@@ -1,11 +1,4 @@
1
- declare const _default: (options?: {}) => {
2
- name: string;
3
- transform(code: any, id: any): Promise<{
4
- code: any;
5
- map: any;
6
- } | null>;
7
- augmentChunkHash(): string | undefined;
8
- generateBundle(options_: any, bundle: any): Promise<void>;
9
- };
10
- export default _default;
1
+ import type { PostCSSPluginConf } from './types.js';
2
+ import type { Plugin as RollupPlugin } from 'rollup';
3
+ export default function rollupPluginPostcss(options: Readonly<PostCSSPluginConf>): RollupPlugin;
11
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/index.ts"],"names":[],"mappings":"yBA6CgB,YAAY;;;;;;;;;AAA5B,wBAgNE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAoD,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAqCvG,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAwM9F"}
@@ -1,16 +1,16 @@
1
- // Fork of rollup-plugin-postcss to fix https://github.com/egoist/rollup-plugin-postcss/issues/184.
2
- // The plugin seems to no longer be maintained and no fork was found.
3
- /* eslint-disable */
4
- // @ts-nocheck
1
+ // Fork of rollup-plugin-postcss v3.0.0 to fix https://github.com/egoist/rollup-plugin-postcss/issues/184
2
+ // and other issues related to package resolution.
5
3
  import path from 'path';
6
4
  import { createFilter } from '@rollup/pluginutils';
7
- import Concat from 'concat-with-sourcemaps';
8
- import Loaders from './loaders.js';
9
- import normalizePath from './utils/normalize-path.js';
5
+ import _concat from 'concat-with-sourcemaps';
6
+ import { Loaders } from './loaders.js';
7
+ import { normalizePath } from './utils/normalize-path.js';
8
+ const Concat = _concat;
10
9
  /**
11
- * The options that could be `boolean` or `object`
12
- * We convert it to an object when it's truthy
13
- * Otherwise fallback to default value
10
+ * Convert an option from `boolean | object` to the expected type.
11
+ * - If object or false, return that value
12
+ * - If true, return an empty object
13
+ * - If undefined, return the default value
14
14
  */
15
15
  function inferOption(option, defaultValue) {
16
16
  if (option === false)
@@ -20,12 +20,7 @@ function inferOption(option, defaultValue) {
20
20
  return option ? {} : defaultValue;
21
21
  }
22
22
  /**
23
- * Recursively get the correct import order from rollup
24
- * We only process a file once
25
- *
26
- * @param {string} id
27
- * @param {Function} getModuleInfo
28
- * @param {Set<string>} seen
23
+ * Recursively get the correct import order from rollup. We only process a file once.
29
24
  */
30
25
  function getRecursiveImportOrder(id, getModuleInfo, seen = new Set()) {
31
26
  if (seen.has(id)) {
@@ -33,34 +28,25 @@ function getRecursiveImportOrder(id, getModuleInfo, seen = new Set()) {
33
28
  }
34
29
  seen.add(id);
35
30
  const result = [id];
36
- getModuleInfo(id).importedIds.forEach((importFile) => {
31
+ getModuleInfo(id)?.importedIds.forEach((importFile) => {
37
32
  result.push(...getRecursiveImportOrder(importFile, getModuleInfo, seen));
38
33
  });
39
34
  return result;
40
35
  }
41
- /* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
42
- export default (options = {}) => {
36
+ export default function rollupPluginPostcss(options) {
43
37
  const filter = createFilter(options.include, options.exclude);
44
38
  const postcssPlugins = Array.isArray(options.plugins) ? options.plugins.filter(Boolean) : options.plugins;
45
39
  const { sourceMap } = options;
46
40
  const postcssLoaderOptions = {
47
- /** Inject CSS as `<style>` to `<head>` */
48
41
  inject: typeof options.inject === 'function' ? options.inject : inferOption(options.inject, {}),
49
- /** Extract CSS */
50
42
  extract: typeof options.extract === 'undefined' ? false : options.extract,
51
- /** CSS modules */
52
43
  onlyModules: options.modules === true,
53
44
  modules: inferOption(options.modules, false),
54
45
  namedExports: options.namedExports,
55
- /** Automatically CSS modules for .module.xxx files */
56
46
  autoModules: options.autoModules,
57
- /** Options for cssnano */
58
47
  minimize: inferOption(options.minimize, false),
59
- /** Postcss config file */
60
- config: inferOption(options.config, false),
61
- /** PostCSS target filename hint, for plugins that are relying on it */
48
+ config: false, // was: inferOption(options.config, false),
62
49
  to: options.to,
63
- /** PostCSS options */
64
50
  postcss: {
65
51
  parser: options.parser,
66
52
  plugins: postcssPlugins,
@@ -71,7 +57,7 @@ export default (options = {}) => {
71
57
  };
72
58
  let use = ['sass', 'less'];
73
59
  if (Array.isArray(options.use)) {
74
- use = options.use;
60
+ ({ use } = options);
75
61
  }
76
62
  else if (options.use !== null && typeof options.use === 'object') {
77
63
  use = [
@@ -95,7 +81,11 @@ export default (options = {}) => {
95
81
  if (typeof options.onImport === 'function') {
96
82
  options.onImport(id);
97
83
  }
84
+ // eslint-disable-next-line no-restricted-properties
85
+ const { inputCwd = process.cwd(), resolveCwd = inputCwd } = options;
98
86
  const loaderContext = {
87
+ resolveCwd,
88
+ inputCwd,
99
89
  id,
100
90
  sourceMap,
101
91
  dependencies: new Set(),
@@ -124,20 +114,16 @@ export default (options = {}) => {
124
114
  augmentChunkHash() {
125
115
  if (extracted.size === 0)
126
116
  return;
127
- // eslint-disable-next-line unicorn/no-reduce
128
- const extractedValue = [...extracted].reduce((object, [key, value]) => ({
129
- ...object,
130
- [key]: value,
131
- }), {});
117
+ const extractedValue = Object.fromEntries([...extracted]);
132
118
  return JSON.stringify(extractedValue);
133
119
  },
134
- async generateBundle(options_, bundle) {
135
- if (extracted.size === 0 || !(options_.dir || options_.file))
120
+ async generateBundle(opts, bundle) {
121
+ if (extracted.size === 0 || !(opts.dir || opts.file))
136
122
  return;
137
123
  // TODO: support `[hash]`
138
- const dir = options_.dir || path.dirname(options_.file);
139
- const file = options_.file ||
140
- path.join(options_.dir, Object.keys(bundle).find((fileName) => bundle[fileName].isEntry));
124
+ const dir = opts.dir || path.dirname(opts.file || '');
125
+ const file = opts.file ||
126
+ path.join(opts.dir || '', Object.keys(bundle).find((fileName) => bundle[fileName].isEntry) || '');
141
127
  const getExtracted = () => {
142
128
  let fileName = `${path.basename(file, path.extname(file))}.css`;
143
129
  if (typeof postcssLoaderOptions.extract === 'string') {
@@ -146,41 +132,44 @@ export default (options = {}) => {
146
132
  : normalizePath(postcssLoaderOptions.extract);
147
133
  }
148
134
  const concat = new Concat(true, fileName, '\n');
149
- const entries = [...extracted.values()];
135
+ const entries = [...extracted.values()].filter(Boolean);
150
136
  const { modules, facadeModuleId } = bundle[normalizePath(path.relative(dir, file))];
151
- if (modules) {
137
+ if (modules && facadeModuleId) {
152
138
  const moduleIds = getRecursiveImportOrder(facadeModuleId, this.getModuleInfo);
153
139
  entries.sort((a, b) => moduleIds.indexOf(a.id) - moduleIds.indexOf(b.id));
154
140
  }
155
141
  for (const result of entries) {
156
142
  const relative = normalizePath(path.relative(dir, result.id));
157
143
  const map = result.map || null;
158
- if (map) {
144
+ if (map && typeof map === 'object') {
159
145
  map.file = fileName;
160
146
  }
161
147
  concat.add(relative, result.code, map);
162
148
  }
163
- let code = concat.content;
149
+ let code = concat.content.toString();
164
150
  if (sourceMap === 'inline') {
165
- code += `\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(concat.sourceMap, 'utf8').toString('base64')}*/`;
151
+ code += `\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(concat.sourceMap || '', 'utf8').toString('base64')}*/`;
166
152
  }
167
153
  else if (sourceMap === true) {
168
154
  code += `\n/*# sourceMappingURL=${path.basename(fileName)}.map */`;
169
155
  }
170
156
  return {
171
157
  code,
172
- map: sourceMap === true && concat.sourceMap,
158
+ map: (sourceMap === true && concat.sourceMap) || undefined,
173
159
  codeFileName: fileName,
174
160
  mapFileName: fileName + '.map',
175
161
  };
176
162
  };
163
+ const extractedFile = getExtracted();
177
164
  if (options.onExtract) {
178
- const shouldExtract = await options.onExtract(getExtracted);
165
+ const shouldExtract = await options.onExtract(extractedFile);
179
166
  if (shouldExtract === false) {
180
167
  return;
181
168
  }
182
169
  }
183
- let { code, codeFileName, map, mapFileName } = getExtracted();
170
+ const { code: initialCode, codeFileName, map: initialMap, mapFileName } = extractedFile;
171
+ let code = initialCode;
172
+ let map = initialMap;
184
173
  // Perform cssnano on the extracted file
185
174
  if (postcssLoaderOptions.minimize) {
186
175
  const cssOptions = {};
@@ -213,5 +202,5 @@ export default (options = {}) => {
213
202
  }
214
203
  },
215
204
  };
216
- };
205
+ }
217
206
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/postcss/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,qEAAqE;AACrE,oBAAoB;AACpB,cAAc;AACd,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,aAAa,MAAM,2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n// The plugin seems to no longer be maintained and no fork was found.\n/* eslint-disable */\n// @ts-nocheck\nimport path from 'path';\nimport { createFilter } from '@rollup/pluginutils';\nimport Concat from 'concat-with-sourcemaps';\nimport Loaders from './loaders.js';\nimport normalizePath from './utils/normalize-path.js';\n\n/**\n * The options that could be `boolean` or `object`\n * We convert it to an object when it's truthy\n * Otherwise fallback to default value\n */\nfunction inferOption(option, defaultValue) {\n if (option === false) return false;\n if (option && typeof option === 'object') return option;\n return option ? {} : defaultValue;\n}\n\n/**\n * Recursively get the correct import order from rollup\n * We only process a file once\n *\n * @param {string} id\n * @param {Function} getModuleInfo\n * @param {Set<string>} seen\n */\nfunction getRecursiveImportOrder(id, getModuleInfo, seen = new Set()) {\n if (seen.has(id)) {\n return [];\n }\n\n seen.add(id);\n\n const result = [id];\n getModuleInfo(id).importedIds.forEach((importFile) => {\n result.push(...getRecursiveImportOrder(importFile, getModuleInfo, seen));\n });\n\n return result;\n}\n\n/* eslint import/no-anonymous-default-export: [2, {\"allowArrowFunction\": true}] */\nexport default (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n const postcssPlugins = Array.isArray(options.plugins) ? options.plugins.filter(Boolean) : options.plugins;\n const { sourceMap } = options;\n const postcssLoaderOptions = {\n /** Inject CSS as `<style>` to `<head>` */\n inject: typeof options.inject === 'function' ? options.inject : inferOption(options.inject, {}),\n /** Extract CSS */\n extract: typeof options.extract === 'undefined' ? false : options.extract,\n /** CSS modules */\n onlyModules: options.modules === true,\n modules: inferOption(options.modules, false),\n namedExports: options.namedExports,\n /** Automatically CSS modules for .module.xxx files */\n autoModules: options.autoModules,\n /** Options for cssnano */\n minimize: inferOption(options.minimize, false),\n /** Postcss config file */\n config: inferOption(options.config, false),\n /** PostCSS target filename hint, for plugins that are relying on it */\n to: options.to,\n /** PostCSS options */\n postcss: {\n parser: options.parser,\n plugins: postcssPlugins,\n syntax: options.syntax,\n stringifier: options.stringifier,\n exec: options.exec,\n },\n };\n let use = ['sass', 'less'];\n if (Array.isArray(options.use)) {\n use = options.use;\n } else if (options.use !== null && typeof options.use === 'object') {\n use = [\n ['sass', options.use.sass || {}],\n ['less', options.use.less || {}],\n ];\n }\n\n use.unshift(['postcss', postcssLoaderOptions]);\n\n const loaders = new Loaders({\n use,\n loaders: options.loaders,\n extensions: options.extensions,\n });\n\n const extracted = new Map();\n\n return {\n name: 'postcss',\n\n async transform(code, id) {\n if (!filter(id) || !loaders.isSupported(id)) {\n return null;\n }\n\n if (typeof options.onImport === 'function') {\n options.onImport(id);\n }\n\n const loaderContext = {\n id,\n sourceMap,\n dependencies: new Set(),\n warn: this.warn.bind(this),\n plugin: this,\n };\n\n const result = await loaders.process(\n {\n code,\n map: undefined,\n },\n loaderContext,\n );\n\n for (const dep of loaderContext.dependencies) {\n this.addWatchFile(dep);\n }\n\n if (postcssLoaderOptions.extract) {\n extracted.set(id, result.extracted);\n return {\n code: result.code,\n map: { mappings: '' },\n };\n }\n\n return {\n code: result.code,\n map: result.map || { mappings: '' },\n };\n },\n\n augmentChunkHash() {\n if (extracted.size === 0) return;\n // eslint-disable-next-line unicorn/no-reduce\n const extractedValue = [...extracted].reduce(\n (object, [key, value]) => ({\n ...object,\n [key]: value,\n }),\n {},\n );\n return JSON.stringify(extractedValue);\n },\n\n async generateBundle(options_, bundle) {\n if (extracted.size === 0 || !(options_.dir || options_.file)) return;\n\n // TODO: support `[hash]`\n const dir = options_.dir || path.dirname(options_.file);\n const file =\n options_.file ||\n path.join(\n options_.dir,\n Object.keys(bundle).find((fileName) => bundle[fileName].isEntry),\n );\n const getExtracted = () => {\n let fileName = `${path.basename(file, path.extname(file))}.css`;\n if (typeof postcssLoaderOptions.extract === 'string') {\n fileName = path.isAbsolute(postcssLoaderOptions.extract)\n ? normalizePath(path.relative(dir, postcssLoaderOptions.extract))\n : normalizePath(postcssLoaderOptions.extract);\n }\n\n const concat = new Concat(true, fileName, '\\n');\n const entries = [...extracted.values()];\n const { modules, facadeModuleId } = bundle[normalizePath(path.relative(dir, file))];\n\n if (modules) {\n const moduleIds = getRecursiveImportOrder(facadeModuleId, this.getModuleInfo);\n entries.sort((a, b) => moduleIds.indexOf(a.id) - moduleIds.indexOf(b.id));\n }\n\n for (const result of entries) {\n const relative = normalizePath(path.relative(dir, result.id));\n const map = result.map || null;\n if (map) {\n map.file = fileName;\n }\n\n concat.add(relative, result.code, map);\n }\n\n let code = concat.content;\n\n if (sourceMap === 'inline') {\n code += `\\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(concat.sourceMap, 'utf8').toString(\n 'base64',\n )}*/`;\n } else if (sourceMap === true) {\n code += `\\n/*# sourceMappingURL=${path.basename(fileName)}.map */`;\n }\n\n return {\n code,\n map: sourceMap === true && concat.sourceMap,\n codeFileName: fileName,\n mapFileName: fileName + '.map',\n };\n };\n\n if (options.onExtract) {\n const shouldExtract = await options.onExtract(getExtracted);\n if (shouldExtract === false) {\n return;\n }\n }\n\n let { code, codeFileName, map, mapFileName } = getExtracted();\n // Perform cssnano on the extracted file\n if (postcssLoaderOptions.minimize) {\n const cssOptions = {};\n cssOptions.from = codeFileName;\n if (sourceMap === 'inline') {\n cssOptions.map = { inline: true };\n } else if (sourceMap === true && map) {\n cssOptions.map = { prev: map };\n cssOptions.to = codeFileName;\n }\n\n const cssnano = (await import('cssnano')).default;\n\n const result = await cssnano(postcssLoaderOptions.minimize).process(code, cssOptions);\n code = result.css;\n\n if (sourceMap === true && result.map && result.map.toString) {\n map = result.map.toString();\n }\n }\n\n this.emitFile({\n fileName: codeFileName,\n type: 'asset',\n source: code,\n });\n if (map) {\n this.emitFile({\n fileName: mapFileName,\n type: 'asset',\n source: map,\n });\n }\n },\n };\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/postcss/index.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,kDAAkD;AAElD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,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AM,EAAE,IAAI;aACb,CAAC,CAAC;YACH,IAAI,GAAG,EAAE,CAAC;gBACR,IAAI,CAAC,QAAQ,CAAC;oBACZ,QAAQ,EAAE,WAAW;oBACrB,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE,GAAG;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of rollup-plugin-postcss v3.0.0 to fix https://github.com/egoist/rollup-plugin-postcss/issues/184\n// and other issues related to package resolution.\n\nimport path from 'path';\nimport { createFilter } from '@rollup/pluginutils';\nimport _concat from 'concat-with-sourcemaps';\nimport { Loaders, type LoadersConstructorOptions } from './loaders.js';\nimport { normalizePath } from './utils/normalize-path.js';\nimport type {\n PostCSSPluginConf,\n ExtractResult,\n ExtractedAsset,\n InternalPostCSSLoaderOptions,\n BaseLoaderContext,\n} from './types.js';\nimport type { ExistingRawSourceMap, OutputChunk, PluginContext, Plugin as RollupPlugin } from 'rollup';\nimport type { ProcessOptions as PostcssProcessOptions } from 'postcss';\n\nconst Concat = _concat as unknown as typeof _concat.default;\n/** `RawSourceMap` type from `source-map` package */\ntype ConcatRawSourceMap = Parameters<InstanceType<typeof _concat.default>['add']>[2];\n\n/**\n * Convert an option from `boolean | object` to the expected type.\n * - If object or false, return that value\n * - If true, return an empty object\n * - If undefined, return the default value\n */\nfunction inferOption<T extends object>(option: T | boolean | undefined, defaultValue: T | false): T | false {\n if (option === false) return false;\n if (option && typeof option === 'object') return option;\n return option ? ({} as T) : defaultValue;\n}\n\n/**\n * Recursively get the correct import order from rollup. We only process a file once.\n */\nfunction getRecursiveImportOrder(id: string, getModuleInfo: PluginContext['getModuleInfo'], seen = new Set<string>()) {\n if (seen.has(id)) {\n return [];\n }\n\n seen.add(id);\n\n const result = [id];\n getModuleInfo(id)?.importedIds.forEach((importFile) => {\n result.push(...getRecursiveImportOrder(importFile, getModuleInfo, seen));\n });\n\n return result;\n}\n\nexport default function rollupPluginPostcss(options: Readonly<PostCSSPluginConf>): RollupPlugin {\n const filter = createFilter(options.include, options.exclude);\n const postcssPlugins = Array.isArray(options.plugins) ? options.plugins.filter(Boolean) : options.plugins;\n const { sourceMap } = options;\n const postcssLoaderOptions: InternalPostCSSLoaderOptions = {\n inject: typeof options.inject === 'function' ? options.inject : inferOption(options.inject, {}),\n extract: typeof options.extract === 'undefined' ? false : options.extract,\n onlyModules: options.modules === true,\n modules: inferOption(options.modules, false),\n namedExports: options.namedExports,\n autoModules: options.autoModules,\n minimize: inferOption(options.minimize, false),\n config: false, // was: inferOption(options.config, false),\n to: options.to,\n postcss: {\n parser: options.parser,\n plugins: postcssPlugins,\n syntax: options.syntax,\n stringifier: options.stringifier,\n exec: options.exec,\n },\n };\n let use: LoadersConstructorOptions['use'] = ['sass', 'less'];\n if (Array.isArray(options.use)) {\n ({ use } = options);\n } else if (options.use !== null && typeof options.use === 'object') {\n use = [\n ['sass', options.use.sass || {}],\n ['less', options.use.less || {}],\n ];\n }\n\n use.unshift(['postcss', postcssLoaderOptions]);\n\n const loaders = new Loaders({\n use,\n loaders: options.loaders,\n extensions: options.extensions,\n });\n\n const extracted = new Map<string, ExtractResult | undefined>();\n\n return {\n name: 'postcss',\n\n async transform(code, id) {\n if (!filter(id) || !loaders.isSupported(id)) {\n return null;\n }\n\n if (typeof options.onImport === 'function') {\n options.onImport(id);\n }\n\n // eslint-disable-next-line no-restricted-properties\n const { inputCwd = process.cwd(), resolveCwd = inputCwd } = options;\n const loaderContext: BaseLoaderContext = {\n resolveCwd,\n inputCwd,\n id,\n sourceMap,\n dependencies: new Set(),\n warn: this.warn.bind(this),\n plugin: this,\n };\n\n const result = await loaders.process(\n {\n code,\n map: undefined,\n },\n loaderContext,\n );\n\n for (const dep of loaderContext.dependencies) {\n this.addWatchFile(dep);\n }\n\n if (postcssLoaderOptions.extract) {\n extracted.set(id, result.extracted);\n return {\n code: result.code,\n map: { mappings: '' },\n };\n }\n\n return {\n code: result.code,\n map: result.map || { mappings: '' },\n };\n },\n\n augmentChunkHash() {\n if (extracted.size === 0) return;\n const extractedValue = Object.fromEntries([...extracted]);\n return JSON.stringify(extractedValue);\n },\n\n async generateBundle(opts, bundle) {\n if (extracted.size === 0 || !(opts.dir || opts.file)) return;\n\n // TODO: support `[hash]`\n const dir = opts.dir || path.dirname(opts.file || '');\n const file =\n opts.file ||\n path.join(\n opts.dir || '',\n Object.keys(bundle).find((fileName) => (bundle[fileName] as OutputChunk).isEntry) || '',\n );\n const getExtracted = (): ExtractedAsset => {\n let fileName = `${path.basename(file, path.extname(file))}.css`;\n if (typeof postcssLoaderOptions.extract === 'string') {\n fileName = path.isAbsolute(postcssLoaderOptions.extract)\n ? normalizePath(path.relative(dir, postcssLoaderOptions.extract))\n : normalizePath(postcssLoaderOptions.extract);\n }\n\n const concat = new Concat(true, fileName, '\\n');\n const entries = [...extracted.values()].filter(Boolean) as ExtractResult[];\n const { modules, facadeModuleId } = bundle[normalizePath(path.relative(dir, file))] as OutputChunk;\n\n if (modules && facadeModuleId) {\n const moduleIds = getRecursiveImportOrder(facadeModuleId, this.getModuleInfo);\n entries.sort((a, b) => moduleIds.indexOf(a.id) - moduleIds.indexOf(b.id));\n }\n\n for (const result of entries) {\n const relative = normalizePath(path.relative(dir, result.id));\n const map = result.map || null;\n if (map && typeof map === 'object') {\n (map as ExistingRawSourceMap).file = fileName;\n }\n\n concat.add(relative, result.code, map as Omit<ExistingRawSourceMap, 'version'> as ConcatRawSourceMap);\n }\n\n let code = concat.content.toString();\n\n if (sourceMap === 'inline') {\n code += `\\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(\n concat.sourceMap || '',\n 'utf8',\n ).toString('base64')}*/`;\n } else if (sourceMap === true) {\n code += `\\n/*# sourceMappingURL=${path.basename(fileName)}.map */`;\n }\n\n return {\n code,\n map: (sourceMap === true && concat.sourceMap) || undefined,\n codeFileName: fileName,\n mapFileName: fileName + '.map',\n };\n };\n\n const extractedFile = getExtracted();\n if (options.onExtract) {\n const shouldExtract = await options.onExtract(extractedFile);\n if (shouldExtract === false) {\n return;\n }\n }\n\n const { code: initialCode, codeFileName, map: initialMap, mapFileName } = extractedFile;\n let code = initialCode;\n let map = initialMap;\n // Perform cssnano on the extracted file\n if (postcssLoaderOptions.minimize) {\n const cssOptions: PostcssProcessOptions = {};\n cssOptions.from = codeFileName;\n if (sourceMap === 'inline') {\n cssOptions.map = { inline: true };\n } else if (sourceMap === true && map) {\n cssOptions.map = { prev: map };\n cssOptions.to = codeFileName;\n }\n\n const cssnano = (await import('cssnano')).default;\n const result = await cssnano(postcssLoaderOptions.minimize).process(code, cssOptions);\n code = result.css;\n\n if (sourceMap === true && result.map && result.map.toString) {\n map = result.map.toString();\n }\n }\n\n this.emitFile({\n fileName: codeFileName,\n type: 'asset',\n source: code,\n });\n if (map) {\n this.emitFile({\n fileName: mapFileName,\n type: 'asset',\n source: map,\n });\n }\n },\n };\n}\n"]}
@@ -1,9 +1,3 @@
1
- declare const _default: {
2
- name: string;
3
- test: RegExp;
4
- process({ code }: {
5
- code: any;
6
- }): any;
7
- };
8
- export default _default;
1
+ import type { LessOptions, Loader } from './types.js';
2
+ export declare const lessLoader: Loader<LessOptions>;
9
3
  //# sourceMappingURL=less-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"less-loader.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/less-loader.ts"],"names":[],"mappings":";;;;;;;AAOA,wBAqCE"}
1
+ {"version":3,"file":"less-loader.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/less-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIlE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,WAAW,CAsC1C,CAAC"}
@@ -1,18 +1,15 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
1
  import pify from 'pify';
4
- import humanlizePath from './utils/humanlize-path.js';
5
2
  import { loadModule } from './utils/load-module.js';
6
- /* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
7
- export default {
3
+ import { normalizePath } from './utils/normalize-path.js';
4
+ export const lessLoader = {
8
5
  name: 'less',
9
6
  test: /\.less$/,
10
7
  async process({ code }) {
11
- const lessModule = await loadModule('less');
8
+ const lessModule = await loadModule({ moduleId: 'less', cwd: this.resolveCwd });
12
9
  if (!lessModule) {
13
10
  throw new Error('You need to install "less" package to process Less files');
14
11
  }
15
- const less = lessModule.default || lessModule;
12
+ const less = 'render' in lessModule ? lessModule : lessModule.default;
16
13
  const renderAsync = pify(less.render.bind(less));
17
14
  const { css, map: initialMap, imports, } = await renderAsync(code, {
18
15
  ...this.options,
@@ -22,10 +19,10 @@ export default {
22
19
  for (const dep of imports) {
23
20
  this.dependencies.add(dep);
24
21
  }
25
- let map = initialMap;
26
- if (map) {
27
- map = JSON.parse(map);
28
- map.sources = map.sources.map((source) => humanlizePath(source));
22
+ let map;
23
+ if (initialMap) {
24
+ map = JSON.parse(initialMap);
25
+ map.sources = map.sources.map((source) => normalizePath(source, { relativeTo: this.inputCwd }));
29
26
  }
30
27
  return {
31
28
  code: css,
@@ -1 +1 @@
1
- {"version":3,"file":"less-loader.js","sourceRoot":"","sources":["../../../src/plugins/postcss/less-loader.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,aAAa,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,2EAA2E;AAC3E,eAAe;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE;QACpB,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEjD,MAAM,EACJ,GAAG,EACH,GAAG,EAAE,UAAU,EACf,OAAO,GACR,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE;YAC1B,GAAG,IAAI,CAAC,OAAO;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,EAAE;SAClB,CAAC,CAAC;QAEH,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,GAAG,GAAG,UAAU,CAAC;QACrB,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtB,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,OAAO;YACL,IAAI,EAAE,GAAG;YACT,GAAG;SACJ,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable */\n// @ts-nocheck\nimport pify from 'pify';\nimport humanlizePath from './utils/humanlize-path.js';\nimport { loadModule } from './utils/load-module.js';\n\n/* eslint import/no-anonymous-default-export: [2, {\"allowObject\": true}] */\nexport default {\n name: 'less',\n test: /\\.less$/,\n async process({ code }) {\n const lessModule = await loadModule('less');\n if (!lessModule) {\n throw new Error('You need to install \"less\" package to process Less files');\n }\n\n const less = lessModule.default || lessModule;\n const renderAsync = pify(less.render.bind(less));\n\n const {\n css,\n map: initialMap,\n imports,\n } = await renderAsync(code, {\n ...this.options,\n sourceMap: this.sourceMap && {},\n filename: this.id,\n });\n\n for (const dep of imports) {\n this.dependencies.add(dep);\n }\n\n let map = initialMap;\n if (map) {\n map = JSON.parse(map);\n map.sources = map.sources.map((source) => humanlizePath(source));\n }\n\n return {\n code: css,\n map,\n };\n },\n};\n"]}
1
+ {"version":3,"file":"less-loader.js","sourceRoot":"","sources":["../../../src/plugins/postcss/less-loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAwB;IAC7C,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IAEf,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE;QACpB,MAAM,UAAU,GAAG,MAAM,UAAU,CAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;QACtE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEjD,MAAM,EACJ,GAAG,EACH,GAAG,EAAE,UAAU,EACf,OAAO,GACR,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE;YAC1B,GAAG,IAAI,CAAC,OAAO;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,EAAE;SAClB,CAAC,CAAC;QAEH,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,GAAqC,CAAC;QAC1C,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAyB,CAAC;YACrD,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;QAED,OAAO;YACL,IAAI,EAAE,GAAG;YACT,GAAG;SACJ,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import pify from 'pify';\nimport { loadModule } from './utils/load-module.js';\nimport type { LessModule, LessOptions, Loader } from './types.js';\nimport type { ExistingRawSourceMap } from 'rollup';\nimport { normalizePath } from './utils/normalize-path.js';\n\nexport const lessLoader: Loader<LessOptions> = {\n name: 'less',\n test: /\\.less$/,\n\n async process({ code }) {\n const lessModule = await loadModule<LessModule>({ moduleId: 'less', cwd: this.resolveCwd });\n if (!lessModule) {\n throw new Error('You need to install \"less\" package to process Less files');\n }\n\n const less = 'render' in lessModule ? lessModule : lessModule.default;\n const renderAsync = pify(less.render.bind(less));\n\n const {\n css,\n map: initialMap,\n imports,\n } = await renderAsync(code, {\n ...this.options,\n sourceMap: this.sourceMap && {},\n filename: this.id,\n });\n\n for (const dep of imports) {\n this.dependencies.add(dep);\n }\n\n let map: ExistingRawSourceMap | undefined;\n if (initialMap) {\n map = JSON.parse(initialMap) as ExistingRawSourceMap;\n map.sources = map.sources.map((source) => normalizePath(source, { relativeTo: this.inputCwd }));\n }\n\n return {\n code: css,\n map,\n };\n },\n};\n"]}
@@ -1,26 +1,20 @@
1
- export default class Loaders {
2
- constructor(options?: {});
3
- registerLoader(loader: any): this;
4
- removeLoader(name: any): this;
5
- isSupported(filepath: any): any;
1
+ import type { BaseLoaderContext, Loader, PostCSSPluginConf, Resource, ResourceResult } from './types.js';
2
+ export type LoadersConstructorOptions = {
3
+ [k in 'loaders' | 'extensions']: PostCSSPluginConf[k];
4
+ } & {
5
+ use: Extract<NonNullable<PostCSSPluginConf['use']>, unknown[]>;
6
+ };
7
+ export declare class Loaders {
8
+ private use;
9
+ private loaders;
10
+ constructor(options: LoadersConstructorOptions);
11
+ registerLoader(loader: Loader<unknown>): this;
12
+ removeLoader(name: string): this;
13
+ isSupported(filepath: string): boolean;
6
14
  /**
7
15
  * Process the resource with loaders in serial
8
- * @param {object} resource
9
- * @param {string} resource.code
10
- * @param {any} resource.map
11
- * @param {object} context
12
- * @param {string} context.id The absolute path to resource
13
- * @param {boolean | 'inline'} context.sourceMap
14
- * @param {Set<string>} context.dependencies A set of dependencies to watch
15
- * @returns {{code: string, map?: any}}
16
16
  */
17
- process({ code, map }: {
18
- code: any;
19
- map: any;
20
- }, context: any): Promise<{
21
- code: any;
22
- map: any;
23
- }>;
24
- getLoader(name: any): any;
17
+ process({ code, map }: Resource, context: BaseLoaderContext): Promise<ResourceResult>;
18
+ getLoader(name: string): Loader<unknown> | undefined;
25
19
  }
26
20
  //# sourceMappingURL=loaders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/loaders.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,OAAO,OAAO,OAAO;gBACd,OAAO,KAAK;IA2BxB,cAAc,CAAC,MAAM,KAAA;IAUrB,YAAY,CAAC,IAAI,KAAA;IAKjB,WAAW,CAAC,QAAQ,KAAA;IAMpB;;;;;;;;;;OAUG;IACG,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE;;;KAAA,EAAE,OAAO,KAAA;;;;IA6BpC,SAAS,CAAC,IAAI,KAAA;CAGf"}
1
+ {"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/loaders.ts"],"names":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