Attempting to build vite-plugin on windows fails with some path related error.
It appears this is something in rollup.config.ts that is mixing windows and posix paths together. Specifically expressions like: path.posix.resolve(__dirname, "src/node/$1") may misbehave on Windows because the __dirname variable contains a windows style path, e.g. C:\Max\chrome-extension-tools\packages\vite-plugin.
Reproduction
ON WINDOWS
load the monorepo for chrome-extension-tools.
pnpm install
cd package/vite-plugin
(cd is C:\Max\chrome-extension-tools\packages\vite-plugin)
pnpm run build
Error message cites a syntactically invalid path with a C:\ in the middle:
> @crxjs/vite-plugin@1.0.14 build C:\Max\chrome-extension-tools\packages\vite-plugin
> run-s build:clean build:js
> @crxjs/vite-plugin@1.0.14 build:clean C:\Max\chrome-extension-tools\packages\vite-plugin
> rimraf dist
> @crxjs/vite-plugin@1.0.14 build:js C:\Max\chrome-extension-tools\packages\vite-plugin
> rollup -c rollup.config.ts --configPlugin esbuild
src/node/index.ts → dist/index.mjs, dist/index.cjs...
[!] (plugin bundleClientCode) Error: Could not load /Max/chrome-extension-tools/packages/vite-plugin/C:\Max\chrome-extension-tools\packages\vite-plugin/src/client/html/precontroller.html?client (imported by src/node/plugin-fileWriter--pages.ts): ENOENT: no such file or directory, open 'C:\Max\chrome-extension-tools\packages\vite-plugin\C:\Max\chrome-extension-tools\packages\vite-plugin\src\client\html\precontroller.html'
Error: Could not load /Max/chrome-extension-tools/packages/vite-plugin/C:\Max\chrome-extension-tools\packages\vite-plugin/src/client/html/precontroller.html?client (imported by src/node/plugin-fileWriter--pages.ts): ENOENT: no such file or directory, open 'C:\Max\chrome-extension-tools\packages\vite-plugin\C:\Max\chrome-extension-tools\packages\vite-plugin\src\client\html\precontroller.html'
ELIFECYCLE Command failed with exit code 1.
ERROR: "build:js" exited with 1.
ELIFECYCLE Command failed with exit code 1.
Build tool
Vite
Where do you see the problem?
Describe the bug
Attempting to build vite-plugin on windows fails with some path related error.
It appears this is something in rollup.config.ts that is mixing windows and posix paths together. Specifically expressions like:
path.posix.resolve(__dirname, "src/node/$1")
may misbehave on Windows because the__dirname
variable contains a windows style path, e.g. C:\Max\chrome-extension-tools\packages\vite-plugin.Reproduction
ON WINDOWS load the monorepo for chrome-extension-tools. pnpm install cd package/vite-plugin (cd is C:\Max\chrome-extension-tools\packages\vite-plugin) pnpm run build
Error message cites a syntactically invalid path with a C:\ in the middle:
/Max/chrome-extension-tools/packages/vite-plugin/C:\Max\chrome-extension-tools\packages\vite-plugin/src/client/html/precontroller.html?client
Logs
System Info
Severity
annoyance