diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 63cb172d052d06..99257e678072b7 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -358,6 +358,13 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { if (ssr) { return [url, null] } + + // Check if the module is marked as external before throwing an error + const externalArray = environment.config.resolve.external + if (Array.isArray(externalArray) && externalArray.includes(url)) { + return [url, null] + } + // fix#9534, prevent the importerModuleNode being stopped from propagating updates importerModule.isSelfAccepting = false moduleGraph._hasResolveFailedErrorModules.add(importerModule) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0711d0387ca5e..821a016a65bf17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1731,6 +1731,46 @@ importers: playground/tsconfig-json-load-error: {} + playground/vite-import-map-testing: + dependencies: + react: + specifier: ^19.1.1 + version: 19.1.1 + react-dom: + specifier: ^19.1.1 + version: 19.1.1(react@19.1.1) + devDependencies: + '@eslint/js': + specifier: ^9.33.0 + version: 9.35.0 + '@types/react': + specifier: ^19.1.10 + version: 19.1.12 + '@types/react-dom': + specifier: ^19.1.7 + version: 19.1.9(@types/react@19.1.12) + '@vitejs/plugin-react': + specifier: ^5.0.0 + version: 5.0.2(vite@packages+vite) + eslint: + specifier: ^9.33.0 + version: 9.35.0(jiti@2.5.1) + eslint-plugin-react-hooks: + specifier: ^5.2.0 + version: 5.2.0(eslint@9.35.0(jiti@2.5.1)) + eslint-plugin-react-refresh: + specifier: ^0.4.20 + version: 0.4.20(eslint@9.35.0(jiti@2.5.1)) + globals: + specifier: ^16.3.0 + version: 16.3.0 + typescript: + specifier: ~5.8.3 + version: 5.8.3 + typescript-eslint: + specifier: ^8.39.1 + version: 8.42.0(eslint@9.35.0(jiti@2.5.1))(typescript@5.8.3) + playground/wasm: {} playground/worker: @@ -2162,6 +2202,18 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-react-jsx-self@7.27.1': + resolution: {integrity: sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-jsx-source@7.27.1': + resolution: {integrity: sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-regenerator@7.28.3': resolution: {integrity: sha512-K3/M/a4+ESb5LEldjQb+XSrpY0nF+ZBFlTCbSnKaYAMfD8v33O6PMs4uYnOk19HlcsI8WMu3McdFPTiQHF/1/A==} engines: {node: '>=6.9.0'} @@ -3022,12 +3074,21 @@ packages: cpu: [x64] os: [win32] + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.37': + resolution: {integrity: sha512-r+RI+wMReoTIF/uXqQWJcD8xGWXzCzUyGdpLmQ8FC+MCyPHlkjEsFRv8OFIYI6HhiGAmbfWVYEGf+aeLJzkHGw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@rolldown/pluginutils@1.0.0-beta.29': resolution: {integrity: sha512-NIJgOsMjbxAXvoGq/X0gD7VPMQ8j9g0BiDaNjVNVjvl+iKXxL3Jre0v31RmBYeLEmkbj2s02v8vFTbUXi5XS2Q==} '@rolldown/pluginutils@1.0.0-beta.44': resolution: {integrity: sha512-g6eW7Zwnr2c5RADIoqziHoVs6b3W5QTQ4+qbpfjbkMJ9x+8Og211VW/oot2dj9dVwaK/UyC6Yo+02gV+wWQVNg==} + '@rolldown/pluginutils@1.0.0-beta.37': + resolution: {integrity: sha512-0taU1HpxFzrukvWIhLRI4YssJX2wOW5q1MxPXWztltsQ13TE51/larZIwhFdpyk7+K43TH7x6GJ8oEqAo+vDbA==} + '@rollup/plugin-alias@5.1.1': resolution: {integrity: sha512-PR9zDb+rOzkRb2VD+EuKB7UC41vU5DIwZ5qqCpk0KJudcWAyi8rvYOhS7+L5aZCspw1stTViLgN5v6FF1p5cgQ==} engines: {node: '>=14.0.0'} @@ -3630,6 +3691,12 @@ packages: terser: ^5.16.0 vite: workspace:* + '@vitejs/plugin-react@5.0.2': + resolution: {integrity: sha512-tmyFgixPZCx2+e6VO9TNITWcCQl8+Nl/E8YbAyPVv85QCc7/A3JrdfG2A8gIzvVhWuzMOVrFW1aReaNxrI6tbw==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + vite: workspace:* + '@vitejs/plugin-vue@6.0.1': resolution: {integrity: sha512-+MaE752hU0wfPFJEUAIxqw18+20euHHdxVtMvbFcOEpjEyfqXH/5DCoTHiVJ0J29EhTJdoTkjEv5YBKU9dnoTw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -4787,6 +4854,17 @@ packages: peerDependencies: eslint: '>=8.23.0' + eslint-plugin-react-hooks@5.2.0: + resolution: {integrity: sha512-+f15FfK64YQwZdJNELETdn5ibXEUQmW1DZL6KXhNnc2heoy/sg9VJJeT7n8TlMWouzWqSWavFkIhHyIbIAEapg==} + engines: {node: '>=10'} + peerDependencies: + eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 + + eslint-plugin-react-refresh@0.4.20: + resolution: {integrity: sha512-XpbHQ2q5gUF8BGOX4dHe+71qoirYMhApEPZ7sfhF/dNnOF1UXnCMGZf79SFTBO7Bz5YEIT4TMieSlJBWhP9WBA==} + peerDependencies: + eslint: '>=8.40' + eslint-plugin-regexp@2.10.0: resolution: {integrity: sha512-ovzQT8ESVn5oOe5a7gIDPD5v9bCSjIFJu57sVPDqgPRXicQzOnYfFN21WoQBQF18vrhT5o7UMKFwJQVVjyJ0ng==} engines: {node: ^18 || >=20} @@ -6438,6 +6516,11 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} hasBin: true + rolldown@1.0.0-beta.37: + resolution: {integrity: sha512-KiTU6z1kHGaLvqaYjgsrv2LshHqNBn74waRZivlK8WbfN1obZeScVkQPKYunB66E/mxZWv/zyZlCv3xF2t0WOQ==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + rollup-plugin-license@3.6.0: resolution: {integrity: sha512-1ieLxTCaigI5xokIfszVDRoy6c/Wmlot1fDEnea7Q/WXSR8AqOjYljHDLObAx7nFxHC2mbxT3QnTSPhaic2IYw==} engines: {node: '>=14.0.0'} @@ -7058,6 +7141,11 @@ packages: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <6.0.0' + typescript@5.8.3: + resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.9.2: resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==} engines: {node: '>=14.17'} @@ -7885,6 +7973,16 @@ snapshots: '@babel/core': 7.28.4 '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-transform-react-jsx-self@7.27.1(@babel/core@7.28.4)': + dependencies: + '@babel/core': 7.28.4 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-react-jsx-source@7.27.1(@babel/core@7.28.4)': + dependencies: + '@babel/core': 7.28.4 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-transform-regenerator@7.28.3(@babel/core@7.28.4)': dependencies: '@babel/core': 7.28.4 @@ -8654,10 +8752,15 @@ snapshots: '@rolldown/binding-win32-x64-msvc@1.0.0-beta.44': optional: true + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.37': + optional: true + '@rolldown/pluginutils@1.0.0-beta.29': {} '@rolldown/pluginutils@1.0.0-beta.44': {} + '@rolldown/pluginutils@1.0.0-beta.37': {} + '@rollup/plugin-alias@5.1.1(rollup@4.43.0)': optionalDependencies: rollup: 4.43.0 @@ -12195,6 +12298,28 @@ snapshots: '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.44 '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.44 + rolldown@1.0.0-beta.37: + dependencies: + '@oxc-project/runtime': 0.87.0 + '@oxc-project/types': 0.87.0 + '@rolldown/pluginutils': 1.0.0-beta.37 + ansis: 4.1.0 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-beta.37 + '@rolldown/binding-darwin-arm64': 1.0.0-beta.37 + '@rolldown/binding-darwin-x64': 1.0.0-beta.37 + '@rolldown/binding-freebsd-x64': 1.0.0-beta.37 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.37 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.37 + '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.37 + '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.37 + '@rolldown/binding-linux-x64-musl': 1.0.0-beta.37 + '@rolldown/binding-openharmony-arm64': 1.0.0-beta.37 + '@rolldown/binding-wasm32-wasi': 1.0.0-beta.37 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.37 + '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.37 + '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.37 + rollup-plugin-license@3.6.0(picomatch@4.0.3)(rollup@4.43.0): dependencies: commenting: 1.1.0 @@ -12778,6 +12903,10 @@ snapshots: trough@2.2.0: {} + ts-api-utils@2.1.0(typescript@5.8.3): + dependencies: + typescript: 5.8.3 + ts-api-utils@2.1.0(typescript@5.9.2): dependencies: typescript: 5.9.2 @@ -12870,6 +12999,8 @@ snapshots: transitivePeerDependencies: - supports-color + typescript@5.8.3: {} + typescript@5.9.2: {} uc.micro@2.1.0: {}