From a3c809595e84fa57ed5eb9326061357af351479f Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 23 Feb 2024 16:38:10 +0900 Subject: [PATCH 01/13] fix: handle css modules as modules --- packages/vite/LICENSE.md | 353 ++---------------- packages/vite/package.json | 2 +- .../src/node/__tests__/plugins/css.spec.ts | 108 +----- packages/vite/src/node/plugins/css.ts | 108 +----- packages/vite/src/node/plugins/index.ts | 2 + .../runtime/__tests__/server-runtime.spec.ts | 4 +- .../__tests__/css-sourcemap.spec.ts | 5 +- playground/css/__tests__/css.spec.ts | 12 +- pnpm-lock.yaml | 67 ++-- 9 files changed, 95 insertions(+), 566 deletions(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 3518027754ee7b..d2b8080265f17a 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -25,7 +25,7 @@ SOFTWARE. # Licenses of bundled dependencies The published Vite artifact additionally contains code with the following licenses: -Apache-2.0, BSD-2-Clause, CC0-1.0, ISC, MIT +Apache-2.0, BSD-2-Clause, ISC, MIT # Bundled dependencies: ## @ampproject/remapping @@ -1053,34 +1053,6 @@ Repository: git@github.com:moxystudio/node-cross-spawn.git --------------------------------------- -## cssesc -License: MIT -By: Mathias Bynens -Repository: https://github.com/mathiasbynens/cssesc.git - -> Copyright Mathias Bynens -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## debug License: MIT By: Josh Junon, TJ Holowaychuk, Nathan Rajlich, Andrew Rhyne @@ -1573,35 +1545,6 @@ Repository: git+https://github.com/isaacs/fs.realpath.git --------------------------------------- -## generic-names -License: MIT -By: Alexey Litvinov -Repository: git+https://github.com/css-modules/generic-names.git - -> The MIT License (MIT) -> -> Copyright (c) 2015 Alexey Litvinov -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - ## glob License: ISC By: Isaac Z. Schlueter @@ -1678,20 +1621,6 @@ Repository: https://github.com/http-party/node-http-proxy.git --------------------------------------- -## icss-utils -License: ISC -By: Glen Maddern -Repository: git+https://github.com/css-modules/icss-utils.git - -> ISC License (ISC) -> Copyright 2018 Glen Maddern -> -> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - ## inflight License: ISC By: Isaac Z. Schlueter @@ -2021,89 +1950,6 @@ Repository: https://github.com/antonk52/lilconfig --------------------------------------- -## loader-utils -License: MIT -By: Tobias Koppers @sokra -Repository: https://github.com/webpack/loader-utils.git - -> Copyright JS Foundation and other contributors -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> 'Software'), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - -## lodash.camelcase -License: MIT -By: John-David Dalton, Blaine Bublitz, Mathias Bynens -Repository: lodash/lodash - -> Copyright jQuery Foundation and other contributors -> -> Based on Underscore.js, copyright Jeremy Ashkenas, -> DocumentCloud and Investigative Reporters & Editors -> -> This software consists of voluntary contributions made by many -> individuals. For exact contribution history, see the revision history -> available at https://github.com/lodash/lodash -> -> The following license applies to all parts of this software except as -> documented below: -> -> ==== -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -> -> ==== -> -> Copyright and related rights for sample code are waived via CC0. Sample -> code is defined as all source code displayed within the prose of the -> documentation. -> -> CC0: http://creativecommons.org/publicdomain/zero/1.0/ -> -> ==== -> -> Files located in the node_modules and vendor directories are externally -> maintained libraries used by this software which have their own -> licenses; we recommend you read them, as their terms may differ from the -> terms above. - ---------------------------------------- - ## magic-string License: MIT By: Rich Harris @@ -2639,135 +2485,6 @@ Repository: postcss/postcss-load-config --------------------------------------- -## postcss-modules -License: MIT -By: Alexander Madyankin -Repository: https://github.com/css-modules/postcss-modules.git - -> The MIT License (MIT) -> -> Copyright 2015-present Alexander Madyankin -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of -> this software and associated documentation files (the "Software"), to deal in -> the Software without restriction, including without limitation the rights to -> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -> the Software, and to permit persons to whom the Software is furnished to do so, -> subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - -## postcss-modules-extract-imports -License: ISC -By: Glen Maddern -Repository: https://github.com/css-modules/postcss-modules-extract-imports.git - -> Copyright 2015 Glen Maddern -> -> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - -## postcss-modules-local-by-default -License: MIT -By: Mark Dalgleish -Repository: https://github.com/css-modules/postcss-modules-local-by-default.git - -> The MIT License (MIT) -> -> Copyright 2015 Mark Dalgleish -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of -> this software and associated documentation files (the "Software"), to deal in -> the Software without restriction, including without limitation the rights to -> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -> the Software, and to permit persons to whom the Software is furnished to do so, -> subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - -## postcss-modules-scope -License: ISC -By: Glen Maddern -Repository: https://github.com/css-modules/postcss-modules-scope.git - -> ISC License (ISC) -> -> Copyright (c) 2015, Glen Maddern -> -> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - -## postcss-modules-values -License: ISC -By: Glen Maddern -Repository: git+https://github.com/css-modules/postcss-modules-values.git - -> ISC License (ISC) -> -> Copyright (c) 2015, Glen Maddern -> -> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - -## postcss-selector-parser -License: MIT -By: Ben Briggs, Chris Eppstein -Repository: postcss/postcss-selector-parser - -> Copyright (c) Ben Briggs (http://beneb.info) -> -> Permission is hereby granted, free of charge, to any person -> obtaining a copy of this software and associated documentation -> files (the "Software"), to deal in the Software without -> restriction, including without limitation the rights to use, -> copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the -> Software is furnished to do so, subject to the following -> conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -> OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## postcss-value-parser License: MIT By: Bogdan Chadkin @@ -3101,13 +2818,6 @@ Repository: jshttp/statuses --------------------------------------- -## string-hash -License: CC0-1.0 -By: The Dark Sky Company -Repository: git://github.com/darkskyapp/string-hash.git - ---------------------------------------- - ## strip-ansi License: MIT By: Sindre Sorhus @@ -3324,38 +3034,6 @@ Repository: stream-utils/unpipe --------------------------------------- -## util-deprecate -License: MIT -By: Nathan Rajlich -Repository: git://github.com/TooTallNate/util-deprecate.git - -> (The MIT License) -> -> Copyright (c) 2014 Nathan Rajlich -> -> Permission is hereby granted, free of charge, to any person -> obtaining a copy of this software and associated documentation -> files (the "Software"), to deal in the Software without -> restriction, including without limitation the rights to use, -> copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the -> Software is furnished to do so, subject to the following -> conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -> OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## utils-merge License: MIT By: Jared Hanson @@ -3414,6 +3092,35 @@ Repository: jshttp/vary --------------------------------------- +## vite-css-modules +License: MIT +By: Hiroki Osame +Repository: privatenumber/vite-css-modules + +> MIT License +> +> Copyright (c) Hiroki Osame +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## which License: ISC By: Isaac Z. Schlueter diff --git a/packages/vite/package.json b/packages/vite/package.json index 2f5809cc63737f..b7d04bd79ca6f7 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -137,7 +137,6 @@ "picomatch": "^2.3.1", "postcss-import": "^16.0.1", "postcss-load-config": "^4.0.2", - "postcss-modules": "^6.0.0", "resolve.exports": "^2.0.2", "rollup-plugin-dts": "^6.1.0", "rollup-plugin-license": "^3.2.0", @@ -149,6 +148,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", + "vite-css-modules": "^1.0.1", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index cfd7dc6e6d4e47..a2192e9bb1491f 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -1,11 +1,6 @@ -import fs from 'node:fs' -import path from 'node:path' -import { describe, expect, test, vi } from 'vitest' -import { resolveConfig } from '../../config' -import type { InlineConfig } from '../../config' +import { describe, expect, test } from 'vitest' import { convertTargets, - cssPlugin, cssUrlRE, getEmptyChunkReplacer, hoistAtRules, @@ -53,71 +48,6 @@ describe('search css url function', () => { }) }) -describe('css modules', () => { - test('css module compose/from path resolutions', async () => { - const mockedProjectPath = path.join(process.cwd(), '/foo/bar/project') - const { transform, resetMock } = await createCssPluginTransform( - { - [path.join(mockedProjectPath, '/css/bar.module.css')]: `\ -.bar { -display: block; -background: #f0f; -}`, - }, - { - resolve: { - alias: [ - { - find: '@', - replacement: mockedProjectPath, - }, - ], - }, - }, - ) - - const result = await transform( - `\ -.foo { -position: fixed; -composes: bar from '@/css/bar.module.css'; -}`, - '/css/foo.module.css', - ) - - expect(result.code).toBe( - `\ -._bar_1csqm_1 { -display: block; -background: #f0f; -} -._foo_86148_1 { -position: fixed; -}`, - ) - - resetMock() - }) - - test('custom generateScopedName', async () => { - const { transform, resetMock } = await createCssPluginTransform(undefined, { - css: { - modules: { - generateScopedName: 'custom__[hash:base64:5]', - }, - }, - }) - const css = `\ -.foo { - color: red; -}` - const result1 = await transform(css, '/foo.module.css') // server - const result2 = await transform(css, '/foo.module.css?direct') // client - expect(result1.code).toBe(result2.code) - resetMock() - }) -}) - describe('hoist @ rules', () => { test('hoist @import', async () => { const css = `.foo{color:red;}@import "bla";` @@ -208,42 +138,6 @@ describe('hoist @ rules', () => { }) }) -async function createCssPluginTransform( - files?: Record, - inlineConfig: InlineConfig = {}, -) { - const config = await resolveConfig(inlineConfig, 'serve') - const { transform, buildStart } = cssPlugin(config) - - // @ts-expect-error buildStart is function - await buildStart.call({}) - - const mockFs = vi - .spyOn(fs, 'readFile') - // @ts-expect-error vi.spyOn not recognize override `fs.readFile` definition. - .mockImplementationOnce((p, encoding, callback) => { - callback(null, Buffer.from(files?.[p] ?? '')) - }) - - return { - async transform(code: string, id: string) { - // @ts-expect-error transform is function - return await transform.call( - { - addWatchFile() { - return - }, - }, - code, - id, - ) - }, - resetMock() { - mockFs.mockReset() - }, - } -} - describe('convertTargets', () => { test('basic cases', () => { expect(convertTargets('es2018')).toStrictEqual({ diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 83b8da61a37c45..2f4da3a9acd0ce 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -12,7 +12,6 @@ import type { RollupError, SourceMapInput, } from 'rollup' -import { dataToEsm } from '@rollup/pluginutils' import colors from 'picocolors' import MagicString from 'magic-string' import type * as PostCSS from 'postcss' @@ -25,6 +24,7 @@ import type { TransformOptions } from 'esbuild' import { formatMessages, transform } from 'esbuild' import type { RawSourceMap } from '@ampproject/remapping' import { WorkerWithFallback } from 'artichokie' +import { pluginName } from 'vite-css-modules'; import { getCodeWithSourcemap, injectSourcesContent } from '../server/sourcemap' import type { ModuleNode } from '../server/moduleGraph' import type { ResolveFn, ViteDevServer } from '../' @@ -226,11 +226,6 @@ export const isDirectCSSRequest = (request: string): boolean => export const isDirectRequest = (request: string): boolean => directRequestRE.test(request) -const cssModulesCache = new WeakMap< - ResolvedConfig, - Map> ->() - export const removedPureCssFilesCache = new WeakMap< ResolvedConfig, Map @@ -252,7 +247,6 @@ const cssUrlAssetRE = /__VITE_CSS_URL__([\da-f]+)__/g */ export function cssPlugin(config: ResolvedConfig): Plugin { const isBuild = config.command === 'build' - let moduleCache: Map> const resolveUrl = config.createResolver({ preferRelative: true, @@ -271,10 +265,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin { name: 'vite:css', buildStart() { - // Ensure a new cache for every build (i.e. rebuilding in watch mode) - moduleCache = new Map>() - cssModulesCache.set(config, moduleCache) - removedPureCssFilesCache.set(config, new Map()) preprocessorWorkerController = createPreprocessorWorkerController( @@ -359,7 +349,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin { const { code: css, - modules, deps, map, } = await compileCSS( @@ -369,9 +358,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin { preprocessorWorkerController!, urlReplacer, ) - if (modules) { - moduleCache.set(id, modules) - } if (deps) { for (const file of deps) { @@ -469,15 +455,18 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } const inlined = inlineRE.test(id) - const modules = cssModulesCache.get(config)!.get(id) - // #6984, #7552 - // `foo.module.css` => modulesCode - // `foo.module.css?inline` => cssContent - const modulesCode = - modules && - !inlined && - dataToEsm(modules, { namedExports: true, preferConst: true }) + const moduleInfo = ( + isModuleCSSRequest(id) + && this.getModuleInfo(id) + ); + const moduleData = moduleInfo && moduleInfo.meta[pluginName]; + + let modulesCode = undefined; + if (moduleData) { + modulesCode = css; + css = moduleData.css; + } if (config.command === 'serve') { const getContentWithSourcemap = async (content: string) => { @@ -525,14 +514,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } let code: string - if (modulesCode) { - code = modulesCode - } else if (inlined) { + if (inlined) { let content = css if (config.build.cssMinify) { content = await minifyCSS(content, config, true) } code = `export default ${JSON.stringify(content)}` + } else if (modulesCode) { + code = modulesCode } else { // empty module when it's not a CSS module nor `?inline` code = '' @@ -951,7 +940,7 @@ export function cssAnalysisPlugin(config: ResolvedConfig): Plugin { if (thisModule) { // CSS modules cannot self-accept since it exports values const isSelfAccepting = - !cssModulesCache.get(config)?.get(id) && + !isModuleCSSRequest(id) && !inlineRE.test(id) && !htmlProxyRE.test(id) // attached by pluginContainer.addWatchFile @@ -1083,12 +1072,6 @@ function createCSSResolvers(config: ResolvedConfig): CSSAtImportResolvers { } } -function getCssResolversKeys( - resolvers: CSSAtImportResolvers, -): Array { - return Object.keys(resolvers) as unknown as Array -} - async function compileCSSPreprocessors( id: string, lang: PreprocessLang, @@ -1179,15 +1162,13 @@ async function compileCSS( code: string map?: SourceMapInput ast?: PostCSS.Result - modules?: Record deps?: Set }> { if (config.css?.transformer === 'lightningcss') { return compileLightningCSS(id, code, config, urlReplacer) } - const { modules: modulesOptions, devSourcemap } = config.css || {} - const isModule = modulesOptions !== false && cssModuleRE.test(id) + const { devSourcemap } = config.css || {} // although at serve time it can work without processing, we do need to // crawl them in order to register watch dependencies. const needInlineImport = code.includes('@import') @@ -1199,14 +1180,12 @@ async function compileCSS( if ( lang === 'css' && !postcssConfig && - !isModule && !needInlineImport && !hasUrl ) { return { code, map: null } } - let modules: Record | undefined const deps = new Set() // 2. pre-processors: sass etc. @@ -1295,35 +1274,6 @@ async function compileCSS( ) } - if (isModule) { - postcssPlugins.unshift( - (await importPostcssModules()).default({ - ...modulesOptions, - localsConvention: modulesOptions?.localsConvention, - getJSON( - cssFileName: string, - _modules: Record, - outputFileName: string, - ) { - modules = _modules - if (modulesOptions && typeof modulesOptions.getJSON === 'function') { - modulesOptions.getJSON(cssFileName, _modules, outputFileName) - } - }, - async resolve(id: string, importer: string) { - for (const key of getCssResolversKeys(atImportResolvers)) { - const resolved = await atImportResolvers[key](id, importer) - if (resolved) { - return path.resolve(resolved) - } - } - - return id - }, - }), - ) - } - if (!postcssPlugins.length) { return { code, @@ -1409,7 +1359,6 @@ async function compileCSS( ast: postcssResult, code: postcssResult.css, map: { mappings: '' }, - modules, deps, } } @@ -1427,7 +1376,6 @@ async function compileCSS( ast: postcssResult, code: postcssResult.css, map: combineSourcemapsIfExists(cleanUrl(id), postcssMap, preprocessorMap), - modules, deps, } } @@ -1445,7 +1393,6 @@ function createCachedImport(imp: () => Promise): () => T | Promise { } } const importPostcssImport = createCachedImport(() => import('postcss-import')) -const importPostcssModules = createCachedImport(() => import('postcss-modules')) const importPostcss = createCachedImport(() => import('postcss')) const preprocessorWorkerControllerCache = new WeakMap< @@ -2687,7 +2634,6 @@ async function compileLightningCSS( urlReplacer?: CssUrlReplacer, ): ReturnType { const deps = new Set() - // Relative path is needed to get stable hash when using CSS modules const filename = cleanUrl(path.relative(config.root, id)) const toAbsolute = (filePath: string) => path.isAbsolute(filePath) ? filePath : path.join(config.root, filePath) @@ -2740,9 +2686,6 @@ async function compileLightningCSS( ? !!config.build.sourcemap : config.css?.devSourcemap, analyzeDependencies: true, - cssModules: cssModuleRE.test(id) - ? config.css?.lightningcss?.cssModules ?? true - : undefined, }) let css = res.code.toString() @@ -2763,27 +2706,10 @@ async function compileLightningCSS( } } - let modules: Record | undefined - if ('exports' in res && res.exports) { - modules = {} - // https://github.com/parcel-bundler/lightningcss/issues/291 - const sortedEntries = Object.entries(res.exports).sort((a, b) => - a[0].localeCompare(b[0]), - ) - for (const [key, value] of sortedEntries) { - modules[key] = value.name - // https://lightningcss.dev/css-modules.html#class-composition - for (const c of value.composes) { - modules[key] += ' ' + c.name - } - } - } - return { code: css, map: 'map' in res ? res.map?.toString() : undefined, deps, - modules, } } diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index fc230c686641b1..5daf292115d201 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -1,4 +1,5 @@ import aliasPlugin, { type ResolverFunction } from '@rollup/plugin-alias' +import { cssModules } from 'vite-css-modules'; import type { ObjectHook } from 'rollup' import type { PluginHookUtils, ResolvedConfig } from '../config' import { isDepsOptimizerEnabled } from '../config' @@ -89,6 +90,7 @@ export async function resolvePlugins( ...normalPlugins, wasmFallbackPlugin(), definePlugin(config), + cssModules(config), cssPostPlugin(config), isBuild && buildHtmlPlugin(config), workerImportMetaUrlPlugin(config), diff --git a/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts b/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts index a27ee8034523e6..80b7e6c631495b 100644 --- a/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts +++ b/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts @@ -41,9 +41,9 @@ describe('vite-runtime initialization', async () => { const module = await runtime.executeUrl('/fixtures/test.module.css') expect(module).toMatchObject({ default: { - test: expect.stringMatching(/^_test_/), + test: expect.stringMatching(/^test-module_/), }, - test: expect.stringMatching(/^_test_/), + test: expect.stringMatching(/^test-module_/), }) }) diff --git a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts index 6706b5dcaae510..16e8d3fb6d014e 100644 --- a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts +++ b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts @@ -154,11 +154,12 @@ describe.runIf(isServe)('serve', () => { }) test('imported sass module', async () => { - const css = await getStyleTagContentIncluding('._imported-sass-module_') + const css = await getStyleTagContentIncluding('_imported-sass-module_') + const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` { - "mappings": "AACE;EACE", + "mappings": "AAAA,CAAC,QAAQ;AACT,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;AACf,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG;", "sources": [ "/root/imported.module.sass", ], diff --git a/playground/css/__tests__/css.spec.ts b/playground/css/__tests__/css.spec.ts index 89226a8fbd5ba1..52225650fb8d6e 100644 --- a/playground/css/__tests__/css.spec.ts +++ b/playground/css/__tests__/css.spec.ts @@ -192,11 +192,11 @@ test('css modules composes/from path resolving', async () => { // check if the generated CSS module class name is indeed using the // format specified in vite.config.js expect(await imported.getAttribute('class')).toMatch( - /.composed-module__apply-color___[\w-]{5}/, + /composed-module__apply-color___[\w-]{5}/, ) expect(await imported.getAttribute('class')).toMatch( - /.composes-path-resolving-module__path-resolving-css___[\w-]{5}/, + /composes-path-resolving-module__path-resolving-css___[\w-]{5}/, ) // @todo HMR is not working on this situation. @@ -213,11 +213,11 @@ test('sass modules composes/from path resolving', async () => { // check if the generated CSS module class name is indeed using the // format specified in vite.config.js expect(await imported.getAttribute('class')).toMatch( - /.composed-module__apply-color___[\w-]{5}/, + /composed-module__apply-color___[\w-]{5}/, ) expect(await imported.getAttribute('class')).toMatch( - /.composes-path-resolving-module__path-resolving-sass___[\w-]{5}/, + /composes-path-resolving-module__path-resolving-sass___[\w-]{5}/, ) // @todo HMR is not working on this situation. @@ -234,11 +234,11 @@ test('less modules composes/from path resolving', async () => { // check if the generated CSS module class name is indeed using the // format specified in vite.config.js expect(await imported.getAttribute('class')).toMatch( - /.composed-module__apply-color___[\w-]{5}/, + /composed-module__apply-color___[\w-]{5}/, ) expect(await imported.getAttribute('class')).toMatch( - /.composes-path-resolving-module__path-resolving-less___[\w-]{5}/, + /composes-path-resolving-module__path-resolving-less___[\w-]{5}/, ) // @todo HMR is not working on this situation. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1dea46182b28cc..82eb17c1808c23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -378,9 +378,6 @@ importers: postcss-load-config: specifier: ^4.0.2 version: 4.0.2(postcss@8.4.35)(ts-node@10.9.2) - postcss-modules: - specifier: ^6.0.0 - version: 6.0.0(postcss@8.4.35) resolve.exports: specifier: ^2.0.2 version: 2.0.2 @@ -414,6 +411,9 @@ importers: ufo: specifier: ^1.4.0 version: 1.4.0 + vite-css-modules: + specifier: ^1.0.1 + version: 1.0.1(lightningcss@1.23.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -7161,10 +7161,6 @@ packages: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} dev: false - /lodash.camelcase@4.3.0: - resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - dev: true - /lodash.clonedeep@4.5.0: resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} dev: false @@ -7984,8 +7980,8 @@ packages: postcss: 8.4.35 dev: true - /postcss-modules-local-by-default@4.0.0(postcss@8.4.35): - resolution: {integrity: sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==} + /postcss-modules-local-by-default@4.0.4(postcss@8.4.35): + resolution: {integrity: sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 @@ -7999,8 +7995,8 @@ packages: postcss-value-parser: 4.2.0 dev: true - /postcss-modules-scope@3.0.0(postcss@8.4.35): - resolution: {integrity: sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==} + /postcss-modules-scope@3.1.1(postcss@8.4.35): + resolution: {integrity: sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 @@ -8025,25 +8021,6 @@ packages: postcss: 8.4.35 dev: true - /postcss-modules@6.0.0(postcss@8.4.35): - resolution: {integrity: sha512-7DGfnlyi/ju82BRzTIjWS5C4Tafmzl3R79YP/PASiocj+aa6yYphHhhKUOEoXQToId5rgyFgJ88+ccOUydjBXQ==} - peerDependencies: - postcss: ^8.0.0 - peerDependenciesMeta: - postcss: - optional: true - dependencies: - generic-names: 4.0.0 - icss-utils: 5.1.0(postcss@8.4.35) - lodash.camelcase: 4.3.0 - postcss: 8.4.35 - postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) - postcss-modules-local-by-default: 4.0.0(postcss@8.4.35) - postcss-modules-scope: 3.0.0(postcss@8.4.35) - postcss-modules-values: 4.0.0(postcss@8.4.35) - string-hash: 1.1.3 - dev: true - /postcss-nested@6.0.1(postcss@8.4.35): resolution: {integrity: sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==} engines: {node: '>=12.0'} @@ -8845,10 +8822,6 @@ packages: engines: {node: '>=0.6.19'} dev: true - /string-hash@1.1.3: - resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} - dev: true - /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -9373,6 +9346,32 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + /vite-css-modules@1.0.1(lightningcss@1.23.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): + resolution: {integrity: sha512-1xlqwSa3Um8fWWDO5v185PEzPHWTG74M2XyH5yTrCsd++6XCGHlhQwMkW5DwUtj04dNTr2F4qBwrzxxqvSlxxg==} + peerDependencies: + lightningcss: ^1.23.0 + postcss: ^8.4.33 + vite: '*' + peerDependenciesMeta: + lightningcss: + optional: true + postcss: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.2.0) + generic-names: 4.0.0 + icss-utils: 5.1.0(postcss@8.4.35) + lightningcss: 1.23.0 + postcss: 8.4.35 + postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) + postcss-modules-local-by-default: 4.0.4(postcss@8.4.35) + postcss-modules-scope: 3.1.1(postcss@8.4.35) + postcss-modules-values: 4.0.0(postcss@8.4.35) + vite: link:packages/vite + transitivePeerDependencies: + - rollup + dev: true + /vite-node@1.3.0: resolution: {integrity: sha512-D/oiDVBw75XMnjAXne/4feCkCEwcbr2SU1bjAhCcfI5Bq3VoOHji8/wCPAfUkDIeohJ5nSZ39fNxM3dNZ6OBOA==} engines: {node: ^18.0.0 || >=20.0.0} From 53b20de9a40bfbaff3e350cf723226fa6a1d639a Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 23 Feb 2024 17:35:29 +0900 Subject: [PATCH 02/13] fix self-resolution --- packages/vite/LICENSE.md | 232 +++++++++++++++++++++++++++++++ packages/vite/tsconfig.base.json | 7 +- 2 files changed, 237 insertions(+), 2 deletions(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index d2b8080265f17a..e24dbb1e3483b5 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -1053,6 +1053,34 @@ Repository: git@github.com:moxystudio/node-cross-spawn.git --------------------------------------- +## cssesc +License: MIT +By: Mathias Bynens +Repository: https://github.com/mathiasbynens/cssesc.git + +> Copyright Mathias Bynens +> +> Permission is hereby granted, free of charge, to any person obtaining +> a copy of this software and associated documentation files (the +> "Software"), to deal in the Software without restriction, including +> without limitation the rights to use, copy, modify, merge, publish, +> distribute, sublicense, and/or sell copies of the Software, and to +> permit persons to whom the Software is furnished to do so, subject to +> the following conditions: +> +> The above copyright notice and this permission notice shall be +> included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## debug License: MIT By: Josh Junon, TJ Holowaychuk, Nathan Rajlich, Andrew Rhyne @@ -1545,6 +1573,35 @@ Repository: git+https://github.com/isaacs/fs.realpath.git --------------------------------------- +## generic-names +License: MIT +By: Alexey Litvinov +Repository: git+https://github.com/css-modules/generic-names.git + +> The MIT License (MIT) +> +> Copyright (c) 2015 Alexey Litvinov +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## glob License: ISC By: Isaac Z. Schlueter @@ -1621,6 +1678,20 @@ Repository: https://github.com/http-party/node-http-proxy.git --------------------------------------- +## icss-utils +License: ISC +By: Glen Maddern +Repository: git+https://github.com/css-modules/icss-utils.git + +> ISC License (ISC) +> Copyright 2018 Glen Maddern +> +> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + ## inflight License: ISC By: Isaac Z. Schlueter @@ -1950,6 +2021,34 @@ Repository: https://github.com/antonk52/lilconfig --------------------------------------- +## loader-utils +License: MIT +By: Tobias Koppers @sokra +Repository: https://github.com/webpack/loader-utils.git + +> Copyright JS Foundation and other contributors +> +> Permission is hereby granted, free of charge, to any person obtaining +> a copy of this software and associated documentation files (the +> 'Software'), to deal in the Software without restriction, including +> without limitation the rights to use, copy, modify, merge, publish, +> distribute, sublicense, and/or sell copies of the Software, and to +> permit persons to whom the Software is furnished to do so, subject to +> the following conditions: +> +> The above copyright notice and this permission notice shall be +> included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## magic-string License: MIT By: Rich Harris @@ -2485,6 +2584,107 @@ Repository: postcss/postcss-load-config --------------------------------------- +## postcss-modules-extract-imports +License: ISC +By: Glen Maddern +Repository: https://github.com/css-modules/postcss-modules-extract-imports.git + +> Copyright 2015 Glen Maddern +> +> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + +## postcss-modules-local-by-default +License: MIT +By: Mark Dalgleish +Repository: https://github.com/css-modules/postcss-modules-local-by-default.git + +> The MIT License (MIT) +> +> Copyright 2015 Mark Dalgleish +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of +> this software and associated documentation files (the "Software"), to deal in +> the Software without restriction, including without limitation the rights to +> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +> the Software, and to permit persons to whom the Software is furnished to do so, +> subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + +## postcss-modules-scope +License: ISC +By: Glen Maddern +Repository: https://github.com/css-modules/postcss-modules-scope.git + +> ISC License (ISC) +> +> Copyright (c) 2015, Glen Maddern +> +> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + +## postcss-modules-values +License: ISC +By: Glen Maddern +Repository: git+https://github.com/css-modules/postcss-modules-values.git + +> ISC License (ISC) +> +> Copyright (c) 2015, Glen Maddern +> +> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + +## postcss-selector-parser +License: MIT +By: Ben Briggs, Chris Eppstein +Repository: postcss/postcss-selector-parser + +> Copyright (c) Ben Briggs (http://beneb.info) +> +> Permission is hereby granted, free of charge, to any person +> obtaining a copy of this software and associated documentation +> files (the "Software"), to deal in the Software without +> restriction, including without limitation the rights to use, +> copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the +> Software is furnished to do so, subject to the following +> conditions: +> +> The above copyright notice and this permission notice shall be +> included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +> OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## postcss-value-parser License: MIT By: Bogdan Chadkin @@ -3034,6 +3234,38 @@ Repository: stream-utils/unpipe --------------------------------------- +## util-deprecate +License: MIT +By: Nathan Rajlich +Repository: git://github.com/TooTallNate/util-deprecate.git + +> (The MIT License) +> +> Copyright (c) 2014 Nathan Rajlich +> +> Permission is hereby granted, free of charge, to any person +> obtaining a copy of this software and associated documentation +> files (the "Software"), to deal in the Software without +> restriction, including without limitation the rights to use, +> copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the +> Software is furnished to do so, subject to the following +> conditions: +> +> The above copyright notice and this permission notice shall be +> included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +> OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## utils-merge License: MIT By: Jared Hanson diff --git a/packages/vite/tsconfig.base.json b/packages/vite/tsconfig.base.json index 15fcd2c74e2a9e..d19ff2967ad72b 100644 --- a/packages/vite/tsconfig.base.json +++ b/packages/vite/tsconfig.base.json @@ -8,6 +8,9 @@ "noImplicitOverride": true, "noUnusedLocals": true, "esModuleInterop": true, - "useUnknownInCatchVariables": false - } + "useUnknownInCatchVariables": false, + "paths": { + "vite": ["./src/node/index.ts"], + }, + }, } From dc5834f9f592b9423b14ce9b1dacca44a110b6fd Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 23 Feb 2024 17:38:12 +0900 Subject: [PATCH 03/13] prettier --- packages/vite/src/node/plugins/css.ts | 26 ++++++++----------------- packages/vite/src/node/plugins/index.ts | 2 +- packages/vite/tsconfig.base.json | 6 +++--- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 2f4da3a9acd0ce..5cd70c088e4aa6 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -24,7 +24,7 @@ import type { TransformOptions } from 'esbuild' import { formatMessages, transform } from 'esbuild' import type { RawSourceMap } from '@ampproject/remapping' import { WorkerWithFallback } from 'artichokie' -import { pluginName } from 'vite-css-modules'; +import { pluginName } from 'vite-css-modules' import { getCodeWithSourcemap, injectSourcesContent } from '../server/sourcemap' import type { ModuleNode } from '../server/moduleGraph' import type { ResolveFn, ViteDevServer } from '../' @@ -456,16 +456,13 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const inlined = inlineRE.test(id) - const moduleInfo = ( - isModuleCSSRequest(id) - && this.getModuleInfo(id) - ); - const moduleData = moduleInfo && moduleInfo.meta[pluginName]; + const moduleInfo = isModuleCSSRequest(id) && this.getModuleInfo(id) + const moduleData = moduleInfo && moduleInfo.meta[pluginName] - let modulesCode = undefined; + let modulesCode = undefined if (moduleData) { - modulesCode = css; - css = moduleData.css; + modulesCode = css + css = moduleData.css } if (config.command === 'serve') { @@ -940,9 +937,7 @@ export function cssAnalysisPlugin(config: ResolvedConfig): Plugin { if (thisModule) { // CSS modules cannot self-accept since it exports values const isSelfAccepting = - !isModuleCSSRequest(id) && - !inlineRE.test(id) && - !htmlProxyRE.test(id) + !isModuleCSSRequest(id) && !inlineRE.test(id) && !htmlProxyRE.test(id) // attached by pluginContainer.addWatchFile const pluginImports = (this as any)._addedImports as | Set @@ -1177,12 +1172,7 @@ async function compileCSS( const postcssConfig = await resolvePostcssConfig(config) // 1. plain css that needs no processing - if ( - lang === 'css' && - !postcssConfig && - !needInlineImport && - !hasUrl - ) { + if (lang === 'css' && !postcssConfig && !needInlineImport && !hasUrl) { return { code, map: null } } diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index 5daf292115d201..7b8637ed513388 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -1,5 +1,5 @@ import aliasPlugin, { type ResolverFunction } from '@rollup/plugin-alias' -import { cssModules } from 'vite-css-modules'; +import { cssModules } from 'vite-css-modules' import type { ObjectHook } from 'rollup' import type { PluginHookUtils, ResolvedConfig } from '../config' import { isDepsOptimizerEnabled } from '../config' diff --git a/packages/vite/tsconfig.base.json b/packages/vite/tsconfig.base.json index d19ff2967ad72b..c281ba16f4d8f2 100644 --- a/packages/vite/tsconfig.base.json +++ b/packages/vite/tsconfig.base.json @@ -10,7 +10,7 @@ "esModuleInterop": true, "useUnknownInCatchVariables": false, "paths": { - "vite": ["./src/node/index.ts"], - }, - }, + "vite": ["./src/node/index.ts"] + } + } } From cc9ab2f7970059399b721cc19d6ba41c17532e63 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 28 Feb 2024 19:47:35 +0900 Subject: [PATCH 04/13] test latest --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 158ac8db262d90..6119da83517b9b 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -149,7 +149,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", - "vite-css-modules": "github:privatenumber/vite-plugin-css-modules#npm/locals-convention", + "vite-css-modules": "github:privatenumber/vite-plugin-css-modules#npm/develop", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 599790b0a3ccd9..bf978df5e41304 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -415,8 +415,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 vite-css-modules: - specifier: github:privatenumber/vite-plugin-css-modules#npm/locals-convention - version: git@github.com+privatenumber/vite-plugin-css-modules/9fb0207e4974cad7caa46eaa4bf446237f63a99f(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) + specifier: github:privatenumber/vite-plugin-css-modules#npm/develop + version: git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -10097,9 +10097,9 @@ packages: name: '@vitejs/test-dep-to-optimize' dev: false - git@github.com+privatenumber/vite-plugin-css-modules/9fb0207e4974cad7caa46eaa4bf446237f63a99f(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): - resolution: {commit: 9fb0207e4974cad7caa46eaa4bf446237f63a99f, repo: git@github.com:privatenumber/vite-plugin-css-modules.git, type: git} - id: git@github.com+privatenumber/vite-plugin-css-modules/9fb0207e4974cad7caa46eaa4bf446237f63a99f + git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): + resolution: {commit: 211b34b44478dff4ccc223c26b74ce55daceaa5c, repo: git@github.com:privatenumber/vite-plugin-css-modules.git, type: git} + id: git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c name: vite-css-modules version: 0.0.0-semantic-release peerDependencies: From afc9bf8f7de0e542f5a52edf722559a8e0fc5c93 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 28 Feb 2024 20:25:47 +0900 Subject: [PATCH 05/13] test latest --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 59 ++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 6119da83517b9b..c5e78d2055cd49 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -149,7 +149,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", - "vite-css-modules": "github:privatenumber/vite-plugin-css-modules#npm/develop", + "vite-css-modules": "^1.1.0", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf978df5e41304..71a7f021391b67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -415,8 +415,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 vite-css-modules: - specifier: github:privatenumber/vite-plugin-css-modules#npm/develop - version: git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) + specifier: ^1.1.0 + version: 1.1.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -9362,6 +9362,32 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + /vite-css-modules@1.1.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): + resolution: {integrity: sha512-NAH3SQPGTkro1vayJ4uvfKz2UN1MMPJ+ZGzLdsdfS87jIicx+xinudYEg4PAAueCCEEHgCzxexMn4BGHC/5h1g==} + peerDependencies: + lightningcss: ^1.23.0 + postcss: ^8.4.33 + vite: '*' + peerDependenciesMeta: + lightningcss: + optional: true + postcss: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.2.0) + generic-names: 4.0.0 + icss-utils: 5.1.0(postcss@8.4.35) + lightningcss: 1.24.0 + postcss: 8.4.35 + postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) + postcss-modules-local-by-default: 4.0.4(postcss@8.4.35) + postcss-modules-scope: 3.1.1(postcss@8.4.35) + postcss-modules-values: 4.0.0(postcss@8.4.35) + vite: link:packages/vite + transitivePeerDependencies: + - rollup + dev: true + /vite-node@1.3.1: resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0} @@ -10096,32 +10122,3 @@ packages: resolution: {directory: playground/worker/dep-to-optimize, type: directory} name: '@vitejs/test-dep-to-optimize' dev: false - - git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): - resolution: {commit: 211b34b44478dff4ccc223c26b74ce55daceaa5c, repo: git@github.com:privatenumber/vite-plugin-css-modules.git, type: git} - id: git@github.com+privatenumber/vite-plugin-css-modules/211b34b44478dff4ccc223c26b74ce55daceaa5c - name: vite-css-modules - version: 0.0.0-semantic-release - peerDependencies: - lightningcss: ^1.23.0 - postcss: ^8.4.33 - vite: '*' - peerDependenciesMeta: - lightningcss: - optional: true - postcss: - optional: true - dependencies: - '@rollup/pluginutils': 5.1.0(rollup@4.2.0) - generic-names: 4.0.0 - icss-utils: 5.1.0(postcss@8.4.35) - lightningcss: 1.24.0 - postcss: 8.4.35 - postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) - postcss-modules-local-by-default: 4.0.4(postcss@8.4.35) - postcss-modules-scope: 3.1.1(postcss@8.4.35) - postcss-modules-values: 4.0.0(postcss@8.4.35) - vite: link:packages/vite - transitivePeerDependencies: - - rollup - dev: true From d170bbdcf8e8a70132b2d5d60e808ffa564e991d Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 28 Feb 2024 20:37:06 +0900 Subject: [PATCH 06/13] wip --- packages/vite/src/node/tsconfig.json | 1 + packages/vite/tsconfig.base.json | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/tsconfig.json b/packages/vite/src/node/tsconfig.json index db8e56fa8449c5..da54708e71ef3f 100644 --- a/packages/vite/src/node/tsconfig.json +++ b/packages/vite/src/node/tsconfig.json @@ -6,6 +6,7 @@ "lib": ["ESNext", "DOM"], "stripInternal": true, "paths": { + "vite": ["./index.ts"], "vite/runtime": ["../runtime"] } } diff --git a/packages/vite/tsconfig.base.json b/packages/vite/tsconfig.base.json index c281ba16f4d8f2..15fcd2c74e2a9e 100644 --- a/packages/vite/tsconfig.base.json +++ b/packages/vite/tsconfig.base.json @@ -8,9 +8,6 @@ "noImplicitOverride": true, "noUnusedLocals": true, "esModuleInterop": true, - "useUnknownInCatchVariables": false, - "paths": { - "vite": ["./src/node/index.ts"] - } + "useUnknownInCatchVariables": false } } From d9362958df4125eb3ef8670e4e1942efe15b4b26 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 28 Feb 2024 20:39:35 +0900 Subject: [PATCH 07/13] wip --- .../src/node/ssr/runtime/__tests__/server-runtime.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts b/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts index 8ea3c96118fce3..bcf06bb91d4005 100644 --- a/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts +++ b/packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts @@ -41,9 +41,9 @@ describe('vite-runtime initialization', async () => { const module = await runtime.executeUrl('/fixtures/test.module.css') expect(module).toMatchObject({ default: { - test: expect.stringMatching(/^test-module_/), + test: expect.stringMatching(/^_test_/), }, - test: expect.stringMatching(/^test-module_/), + test: expect.stringMatching(/^_test_/), }) }) From d78a93ee86ffd66c16d5fc35e695b9226bb5cbbe Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Thu, 29 Feb 2024 08:33:38 +0900 Subject: [PATCH 08/13] feat: getJSON & globalModulePaths --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index c5e78d2055cd49..5284a62bec642a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -149,7 +149,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", - "vite-css-modules": "^1.1.0", + "vite-css-modules": "^1.2.0", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 71a7f021391b67..2a7d145c9d464a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -415,8 +415,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 vite-css-modules: - specifier: ^1.1.0 - version: 1.1.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) + specifier: ^1.2.0 + version: 1.2.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -9362,8 +9362,8 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - /vite-css-modules@1.1.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): - resolution: {integrity: sha512-NAH3SQPGTkro1vayJ4uvfKz2UN1MMPJ+ZGzLdsdfS87jIicx+xinudYEg4PAAueCCEEHgCzxexMn4BGHC/5h1g==} + /vite-css-modules@1.2.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): + resolution: {integrity: sha512-vetV4jll5pvynuaeb91G2KX/KLoUXhlNqM7g9cpg8MmzuaVSARZJL8h5wmmfkUmyTKfILh8wbKYOyJwCGAHcTg==} peerDependencies: lightningcss: ^1.23.0 postcss: ^8.4.33 From 4261c589d91ba7733ab79dffea91370fc24ea445 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 6 Mar 2024 17:54:47 +0900 Subject: [PATCH 09/13] wip --- packages/vite/package.json | 2 +- .../__tests__/css-sourcemap.spec.ts | 2 +- pnpm-lock.yaml | 46 +++++++++++++++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 5284a62bec642a..42a83c8887f477 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -149,7 +149,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", - "vite-css-modules": "^1.2.0", + "vite-css-modules": "^1.4.0", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts index 16e8d3fb6d014e..c513afa2e27a07 100644 --- a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts +++ b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts @@ -159,7 +159,7 @@ describe.runIf(isServe)('serve', () => { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` { - "mappings": "AAAA,CAAC,QAAQ;AACT,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;AACf,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG;", + "mappings": "AACE;EACE", "sources": [ "/root/imported.module.sass", ], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a7d145c9d464a..52ee58d79dd3fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -415,8 +415,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 vite-css-modules: - specifier: ^1.2.0 - version: 1.2.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) + specifier: ^1.4.0 + version: 1.4.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -1694,6 +1694,14 @@ packages: '@jridgewell/gen-mapping': 0.3.2 '@jridgewell/trace-mapping': 0.3.23 + /@ampproject/remapping@2.3.0: + resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + dev: true + /@babel/code-frame@7.23.5: resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==} engines: {node: '>=6.9.0'} @@ -3633,6 +3641,15 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 '@jridgewell/trace-mapping': 0.3.23 + /@jridgewell/gen-mapping@0.3.5: + resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.2.1 + '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping': 0.3.25 + dev: true + /@jridgewell/resolve-uri@3.1.2: resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -3641,6 +3658,11 @@ packages: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} engines: {node: '>=6.0.0'} + /@jridgewell/set-array@1.2.1: + resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} + engines: {node: '>=6.0.0'} + dev: true + /@jridgewell/source-map@0.3.3: resolution: {integrity: sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==} dependencies: @@ -3657,6 +3679,13 @@ packages: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 + /@jridgewell/trace-mapping@0.3.25: + resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: @@ -7231,6 +7260,13 @@ packages: dependencies: '@jridgewell/sourcemap-codec': 1.4.15 + /magic-string@0.30.8: + resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /make-dir@2.1.0: resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} engines: {node: '>=6'} @@ -9362,8 +9398,8 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - /vite-css-modules@1.2.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): - resolution: {integrity: sha512-vetV4jll5pvynuaeb91G2KX/KLoUXhlNqM7g9cpg8MmzuaVSARZJL8h5wmmfkUmyTKfILh8wbKYOyJwCGAHcTg==} + /vite-css-modules@1.4.0(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.2.0)(vite@packages+vite): + resolution: {integrity: sha512-N1AP4Nwnwq9tIv7NiLaa9LGr/TU8KKBeRvUCrPMBvf93kSVsj7pghMgsvkoXYMpmYMfIyeKtDzyDTH2tATn3dw==} peerDependencies: lightningcss: ^1.23.0 postcss: ^8.4.33 @@ -9374,10 +9410,12 @@ packages: postcss: optional: true dependencies: + '@ampproject/remapping': 2.3.0 '@rollup/pluginutils': 5.1.0(rollup@4.2.0) generic-names: 4.0.0 icss-utils: 5.1.0(postcss@8.4.35) lightningcss: 1.24.0 + magic-string: 0.30.8 postcss: 8.4.35 postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) postcss-modules-local-by-default: 4.0.4(postcss@8.4.35) From 333d27f7ad84104d2ab468c22720aefa2d52279a Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 8 Mar 2024 12:31:28 +0900 Subject: [PATCH 10/13] support direct --- packages/vite/src/node/plugins/css.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 50f88ceb91c624..a251dbd511bea9 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -477,8 +477,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } if (isDirectCSSRequest(id)) { - return null + return await getContentWithSourcemap(css); } + // server only if (options?.ssr) { return modulesCode || `export default ${JSON.stringify(css)}` @@ -487,13 +488,13 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return `export default ${JSON.stringify(css)}` } - const cssContent = await getContentWithSourcemap(css) + const cssWithMap = await getContentWithSourcemap(css) const code = [ `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify( path.posix.join(config.base, CLIENT_PUBLIC_PATH), )}`, `const __vite__id = ${JSON.stringify(id)}`, - `const __vite__css = ${JSON.stringify(cssContent)}`, + `const __vite__css = ${JSON.stringify(cssWithMap)}`, `__vite__updateStyle(__vite__id, __vite__css)`, // css modules exports change on edit so it can't self accept `${modulesCode || 'import.meta.hot.accept()'}`, From 7cdc30e9b44f281b3e299020a5691df15d4889cd Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 8 Mar 2024 12:38:04 +0900 Subject: [PATCH 11/13] support direct --- packages/vite/src/node/plugins/css.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index a251dbd511bea9..1295c4094440a9 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -477,7 +477,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } if (isDirectCSSRequest(id)) { - return await getContentWithSourcemap(css); + return css; } // server only From 67e93c80775c9650742ec6561fb595c87e754f14 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Fri, 8 Mar 2024 12:48:54 +0900 Subject: [PATCH 12/13] support direct --- packages/vite/src/node/plugins/css.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 1295c4094440a9..91364984b94036 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -477,7 +477,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } if (isDirectCSSRequest(id)) { - return css; + return css } // server only From cdd1a7afda47aa111e24aa3b9bfd59b3fe0b49b9 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 13 Mar 2024 05:09:48 +0900 Subject: [PATCH 13/13] upgrade --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 69 +++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 20751ff93c61be..99fb0496fcf61d 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -139,7 +139,6 @@ "picomatch": "^2.3.1", "postcss-import": "^16.0.1", "postcss-load-config": "^4.0.2", - "postcss-modules": "^6.0.0", "resolve.exports": "^2.0.2", "rollup-plugin-dts": "^6.1.0", "rollup-plugin-esbuild": "^6.1.1", @@ -152,6 +151,7 @@ "tslib": "^2.6.2", "types": "link:./types", "ufo": "^1.4.0", + "vite-css-modules": "^1.4.2", "ws": "^8.16.0" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 421f405d232e43..b9f8c473321ae4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -384,9 +384,6 @@ importers: postcss-load-config: specifier: ^4.0.2 version: 4.0.2(postcss@8.4.35)(ts-node@10.9.2) - postcss-modules: - specifier: ^6.0.0 - version: 6.0.0(postcss@8.4.35) resolve.exports: specifier: ^2.0.2 version: 2.0.2 @@ -423,6 +420,9 @@ importers: ufo: specifier: ^1.4.0 version: 1.4.0 + vite-css-modules: + specifier: ^1.4.2 + version: 1.4.2(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.13.0)(vite@packages+vite) ws: specifier: ^8.16.0 version: 8.16.0 @@ -7203,10 +7203,6 @@ packages: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} dev: false - /lodash.camelcase@4.3.0: - resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - dev: true - /lodash.clonedeep@4.5.0: resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} dev: false @@ -8022,8 +8018,8 @@ packages: postcss: 8.4.35 dev: true - /postcss-modules-local-by-default@4.0.0(postcss@8.4.35): - resolution: {integrity: sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==} + /postcss-modules-local-by-default@4.0.4(postcss@8.4.35): + resolution: {integrity: sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 @@ -8037,8 +8033,8 @@ packages: postcss-value-parser: 4.2.0 dev: true - /postcss-modules-scope@3.0.0(postcss@8.4.35): - resolution: {integrity: sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==} + /postcss-modules-scope@3.1.1(postcss@8.4.35): + resolution: {integrity: sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 @@ -8063,25 +8059,6 @@ packages: postcss: 8.4.35 dev: true - /postcss-modules@6.0.0(postcss@8.4.35): - resolution: {integrity: sha512-7DGfnlyi/ju82BRzTIjWS5C4Tafmzl3R79YP/PASiocj+aa6yYphHhhKUOEoXQToId5rgyFgJ88+ccOUydjBXQ==} - peerDependencies: - postcss: ^8.0.0 - peerDependenciesMeta: - postcss: - optional: true - dependencies: - generic-names: 4.0.0 - icss-utils: 5.1.0(postcss@8.4.35) - lodash.camelcase: 4.3.0 - postcss: 8.4.35 - postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) - postcss-modules-local-by-default: 4.0.0(postcss@8.4.35) - postcss-modules-scope: 3.0.0(postcss@8.4.35) - postcss-modules-values: 4.0.0(postcss@8.4.35) - string-hash: 1.1.3 - dev: true - /postcss-nested@6.0.1(postcss@8.4.35): resolution: {integrity: sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==} engines: {node: '>=12.0'} @@ -8903,10 +8880,6 @@ packages: engines: {node: '>=0.6.19'} dev: true - /string-hash@1.1.3: - resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} - dev: true - /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -9431,6 +9404,34 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + /vite-css-modules@1.4.2(lightningcss@1.24.0)(postcss@8.4.35)(rollup@4.13.0)(vite@packages+vite): + resolution: {integrity: sha512-WDTgxeSZ6Z0RR1dU+Y+0utFR98g0F4yRspBN4em8tUUIbv70knajR26marzJbkRyX0+Erhd4OKT3Zq0fKzu1rg==} + peerDependencies: + lightningcss: ^1.23.0 + postcss: ^8.4.33 + vite: '*' + peerDependenciesMeta: + lightningcss: + optional: true + postcss: + optional: true + dependencies: + '@ampproject/remapping': 2.3.0 + '@rollup/pluginutils': 5.1.0(rollup@4.13.0) + generic-names: 4.0.0 + icss-utils: 5.1.0(postcss@8.4.35) + lightningcss: 1.24.0 + magic-string: 0.30.8 + postcss: 8.4.35 + postcss-modules-extract-imports: 3.0.0(postcss@8.4.35) + postcss-modules-local-by-default: 4.0.4(postcss@8.4.35) + postcss-modules-scope: 3.1.1(postcss@8.4.35) + postcss-modules-values: 4.0.0(postcss@8.4.35) + vite: link:packages/vite + transitivePeerDependencies: + - rollup + dev: true + /vite-node@1.3.1: resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0}