Webpack/rspack call load and transform with escaped paths

Open
#591 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript, webpack
Domain
build-system

Research direction

Start with the hash-path reproduction in test/fixtures/hash-path/unplugin.js and review PR #592 for the proposed scope. Trace how the webpack loader in dist/webpack/loaders/load.mjs passes the escaped path to load and transform, then use the fixture's assertUnescapedId checks to verify that both helpers receive usable paths.

Written by the indexing model from the issue text.

Description

bug
Environment

unplugin 3.1.0

Reproduction

See PR #592. Without the changes to src, added test fails with message:

Error: load received escaped id: "C:\\Users\\edemaine\\Projects\\unplugin\\test\\fixtures\\hash-path\\src\\msg\u0000#hash.js"
    at assertUnescapedId (C:\Users\edemaine\Projects\unplugin\test\fixtures\hash-path\unplugin.js:11:11)
    at Object.load (C:\Users\edemaine\Projects\unplugin\test\fixtures\hash-path\unplugin.js:33:7)
    at Object.load (file:///C:/Users/edemaine/Projects/unplugin/dist/webpack/loaders/load.mjs:14:28)
    at LOADER_EXECUTION (C:\Users\edemaine\Projects\unplugin\node_modules\.pnpm\loader-runner@4.3.1\node_modules\loader-runner\lib\LoaderRunner.js:195:14)
    at runSyncOrAsync (C:\Users\edemaine\Projects\unplugin\node_modules\.pnpm\loader-runner@4.3.1\node_modules\loader-runner\lib\LoaderRunner.js:196:5)
    at iterateNormalLoaders (C:\Users\edemaine\Projects\unplugin\node_modules\.pnpm\loader-runner@4.3.1\node_modules\loader-runner\lib\LoaderRunner.js:258:2)
    at processResourceCallback (C:\Users\edemaine\Projects\unplugin\node_modules\.pnpm\loader-runner@4.3.1\node_modules\loader-runner\lib\LoaderRunner.js:282:5)
    at Object.processResource (C:\Users\edemaine\Projects\unplugin\node_modules\.pnpm\webpack@5.104.1_esbuild@0.27.2_webpack-cli@6.0.1\node_modules\webpack\lib\NormalModule.js:1094:14)
Describe the bug

Webpack for example escapes # in paths into \0#. These paths get passed into load and transform helpers, which makes it hard to actually load the file in a cross-platform way.

Additional context

No response

Logs

Dominant language
TypeScript
Stars
3.6k
Forks
156
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unjs/unplugin

All issues in unjs/unplugin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.