Skip to content

fix: handle + symbol in package subpath exports during dep optimization#21886

Merged
sapphi-red merged 4 commits intomainfrom
copilot/vite-8-fix-import-package-plus-symbol
Mar 16, 2026
Merged

fix: handle + symbol in package subpath exports during dep optimization#21886
sapphi-red merged 4 commits intomainfrom
copilot/vite-8-fix-import-package-plus-symbol

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

  • Identify root cause: flattenId doesn't replace + symbols, causing mismatch between expected and actual rolldown chunk filenames
  • Fix flattenId in packages/vite/src/node/utils.ts to replace + with _____ underscores
  • Add unit test for + symbol handling in flattenId in utils.spec.ts
  • Add proper playground test package dep-with-plus-subpath/ with @vitejs/test-dep-with-plus-subpath name following the convention
  • Register the package as a file dependency in playground/optimize-deps/package.json
  • Extend E2E test flatten id should generate correctly to cover + in subpath
  • Update HTML import to use @vitejs/test-dep-with-plus-subpath/core+feature
  • Run pnpm install to generate proper lockfile entry and symlink
  • Run lint (passes), build (passes), and unit tests (all pass)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Vite 8] Error when importing package with + symbol</issue_title>
<issue_description>### Describe the bug

We maintain an NPM package which utilizes + (plus) symbols in its subpath exports.

For example, you can import:

import Ravelin from 'ravelinjs/core+track+encrypt+promise';

This import no longer resolves correctly with Vite 8. It appears to be related to the + symbol used in the import path. This import worked correctly in Vite 7 and with other build tools. See the reproduction repo and the steps to reproduce for more details about the error.

Reproduction

https://github.com/daronspence/ravelinjs-bug

Steps to reproduce

  • Run npm install followed by npm run dev
  • This gives an error:
file:///Users/tim/Dev/ravelinjs-bug/node_modules/vite/dist/node/chunks/node.js:31312
					const { exportsData, file, id, ...info } = depForEntryFileName[chunk.fileName];
					        ^

TypeError: Error during dependency optimization:

Cannot destructure property 'exportsData' of 'depForEntryFileName[chunk.fileName]' as it is undefined.
    at file:///Users/tim/Dev/ravelinjs-bug/node_modules/vite/dist/node/chunks/node.js:31312:14

System Info

System:
    OS: macOS 26.3
    CPU: (10) arm64 Apple M4
    Memory: 2.93 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.8.1 - /Users/tim/.nvm/versions/node/v25.8.1/bin/node
    npm: 11.11.0 - /Users/tim/.nvm/versions/node/v25.8.1/bin/npm
  Browsers:
    Safari: 26.3
  npmPackages:
    vite: ^8.0 => 8.0.0

Used Package Manager

npm

Logs

No response

Validations

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] [VITE-8] Fix error when importing package with + symbol fix: handle + symbol in package subpath exports during dep optimization Mar 16, 2026
Copilot AI requested a review from sapphi-red March 16, 2026 11:48
@sapphi-red
Copy link
Copy Markdown
Member

@copilot the dep-with-plus-subpath package is missing. also make sure to name the local package as @vitejs/test-*

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot the dep-with-plus-subpath package is missing. also make sure to name the local package as @vitejs/test-*

Fixed in 4a1c0bc. Created playground/optimize-deps/dep-with-plus-subpath/ as a proper local package named @vitejs/test-dep-with-plus-subpath, registered it as a file: dependency in package.json, and ran pnpm install to generate the lockfile entry and symlink. Updated the HTML import to use @vitejs/test-dep-with-plus-subpath/core+feature.

@sapphi-red sapphi-red marked this pull request as ready for review March 16, 2026 12:24
@sapphi-red sapphi-red marked this pull request as draft March 16, 2026 12:24
@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release feat: deps optimizer Esbuild Dependencies Optimization labels Mar 16, 2026
@sapphi-red sapphi-red marked this pull request as ready for review March 16, 2026 13:35
@sapphi-red sapphi-red merged commit 86db93d into main Mar 16, 2026
24 checks passed
@sapphi-red sapphi-red deleted the copilot/vite-8-fix-import-package-plus-symbol branch March 16, 2026 13:42
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Mar 31, 2026
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.3.1 | 8.0.3 |


## [v8.0.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-803-2026-03-26-small)

##### Features

- update rolldown to 1.0.0-rc.12 ([#22024](vitejs/vite#22024)) ([84164ef](vitejs/vite@84164ef))

##### Bug Fixes

- **html:** cache unfiltered CSS list to prevent missing styles across entries ([#22017](vitejs/vite#22017)) ([5464190](vitejs/vite@5464190))
- **module-runner:** handle non-ascii characters in base64 sourcemaps ([#21985](vitejs/vite#21985)) ([77c95bf](vitejs/vite@77c95bf))
- **module-runner:** skip re-import if the runner is closed ([#22020](vitejs/vite#22020)) ([ee2c2cd](vitejs/vite@ee2c2cd))
- **optimizer:** scan is not resolving sub path import if used in a glob import ([#22018](vitejs/vite#22018)) ([ddfe20d](vitejs/vite@ddfe20d))
- **ssr:** ssrTransform incorrectly rewrites `meta` identifier inside `import.meta` when a binding named `meta` exists ([#22019](vitejs/vite#22019)) ([cff5f0c](vitejs/vite@cff5f0c))

##### Miscellaneous Chores

- **deps:** bump picomatch from 4.0.3 to 4.0.4 ([#22027](vitejs/vite#22027)) ([7e56003](vitejs/vite@7e56003))

##### Tests

- **html:** add tests for `getCssFilesForChunk` ([#22016](vitejs/vite#22016)) ([43fbbf9](vitejs/vite@43fbbf9))


## [v8.0.2](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-802-2026-03-23-small)

##### Features

- update rolldown to 1.0.0-rc.11 ([#21998](vitejs/vite#21998)) ([ff91c31](vitejs/vite@ff91c31))

##### Bug Fixes

- **deps:** update all non-major dependencies ([#21988](vitejs/vite#21988)) ([9b7d150](vitejs/vite@9b7d150))

##### Miscellaneous Chores

- **deps:** update dependency [@vitejs/devtools](https://github.com/vitejs/devtools) to ^0.1.5 ([#21992](vitejs/vite#21992)) ([b2dd65b](vitejs/vite@b2dd65b))


## [v8.0.1](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-801-2026-03-19-small)

##### Features

- update rolldown to 1.0.0-rc.10 ([#21932](vitejs/vite#21932)) ([b3c067d](vitejs/vite@b3c067d))

##### Bug Fixes

- **bundled-dev:** properly disable `inlineConst` optimization ([#21865](vitejs/vite#21865)) ([6d97142](vitejs/vite@6d97142))
- **css:** lightningcss minify failed when `build.target: 'es6'` ([#21933](vitejs/vite#21933)) ([5fcce46](vitejs/vite@5fcce46))
- **deps:** update all non-major dependencies ([#21878](vitejs/vite#21878)) ([6dbbd7f](vitejs/vite@6dbbd7f))
- **dev:** always use ESM Oxc runtime ([#21829](vitejs/vite#21829)) ([d323ed7](vitejs/vite@d323ed7))
- **dev:** handle concurrent restarts in `_createServer` ([#21810](vitejs/vite#21810)) ([40bc729](vitejs/vite@40bc729))
- handle `+` symbol in package subpath exports during dep optimization ([#21886](vitejs/vite#21886)) ([86db93d](vitejs/vite@86db93d))
- improve `no-cors` request block error ([#21902](vitejs/vite#21902)) ([5ba688b](vitejs/vite@5ba688b))
- use precise regexes for transform filter to avoid backtracking ([#21800](vitejs/vite#21800)) ([dbe41bd](vitejs/vite@dbe41bd))
- **worker:** `require(json)` result should not be wrapped ([#21847](vitejs/vite#21847)) ([0672fd2](vitejs/vite@0672fd2))
- **worker:** make worker output consistent with client and SSR ([#21871](vitejs/vite#21871)) ([69454d7](vitejs/vite@69454d7))

##### Miscellaneous Chores

- add changelog rearrange script ([#21835](vitejs/vite#21835)) ([efef073](vitejs/vite@efef073))
- **deps:** bump required `@vitejs/devtools` version to 0.1+ ([#21925](vitejs/vite#21925)) ([12932f5](vitejs/vite@12932f5))
- **deps:** update rolldown-related dependencies ([#21787](vitejs/vite#21787)) ([1af1d3a](vitejs/vite@1af1d3a))
- rearrange 8.0 changelog ([8e05b61](vitejs/vite@8e05b61))
- rearrange 8.0 changelog ([#21834](vitejs/vite#21834)) ([86edeee](vitejs/vite@86edeee))


## [v8.0.0](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#800-2026-03-12)

##### Features

- update rolldown to 1.0.0-rc.9 ([#21813](vitejs/vite#21813)) ([f05be0e](vitejs/vite@f05be0e))
- warn when `vite-tsconfig-paths` plugin is detected ([#21781](vitejs/vite#21781)) ([ada493e](vitejs/vite@ada493e))

##### Bug Fixes

- **deps:** update all non-major dependencies ([#21786](vitejs/vite#21786)) ([eaa4352](vitejs/vite@eaa4352))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: deps optimizer Esbuild Dependencies Optimization p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Vite 8] Error when importing package with + symbol

2 participants