elm-pages icon indicating copy to clipboard operation
elm-pages copied to clipboard

`import userInit` fails in pages built on Windows

Open evanj2357 opened this issue 3 years ago • 1 comments

The Javascript import generated by wrapHtml at elm-pages/generator/src/pre-render-html.js:43 breaks when building on Windows 10 due to platform-dependent behavior in path.join. Specifically, when I run elm-pages dev on Windows 10 and visit the dev server at https://localhost:1234, Chrome reports Uncaught TypeError: Failed to resolve module specifier "index.js". Relative references must start with either "/", "./", or "../". in the console. Firefox reports the same error. The error is due to a backslash in the import path (ex. import userInit from"\index.js";), which occurs because path.join uses backslashes to join paths on Windows.

Replacing path.join with path.posix.join in this instance seems to fix the problem by forcing the use of forward slashes in the generated path.

Software versions: Node v16.8.0 Elm 0.19.1 elm-pages v2.1.9 (npm) Chrome 92.0.4515.159 Firefox 91.0.2 Windows 10 version 21H1

evanj2357 avatar Sep 03 '21 02:09 evanj2357

Thank you for filing the issue @evanj2357. I think we have a fix for this. The next release will go out once #256 is resolved.

dillonkearns avatar Nov 24 '21 20:11 dillonkearns