remix-pwa: [v3] Path resolution issue on Windows + broken build script

Hi,

I’m attempting to upgrade to v3, but running into some problems. First, it appears there may be a path resolution issue on Windows. When I try to run remix-pwa build or remix-pwa dev, I get the following error:

> remix-pwa build

node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:405:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:131:11)
    at defaultLoad (node:internal/modules/esm/load:82:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

Windows 11 Node 18

@remix-pwa/cache: 2.0.5 @remix-pwa/strategy: 2.1.3 @remix-pwa/sw: 2.1.4 @remix-pwa/dev: 2.0.19 @remix-pwa/worker-runtime: 2.0.5 remix-pwa: 3.0.10

P.S. To confirm this was a Windows thing, I attempted to build the worker on macOS and it doesn’t error, but it doesn’t build the worker either (doesn’t show up in public). However, remix-pwa dev DOES build the worker (public/entry.worker.js). Still investigating that one.

Thanks for all your work!

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 37 (23 by maintainers)

Most upvoted comments

I created a PR to solve all the windows related issues in the compiler! I did run some test in a Windows 11 computer myself and was the service-worker was bundled correctly.

Success, thank you!

npm notice === Tarball Details === 
npm notice name:          @remix-pwa/dev                          
npm notice version:       2.0.26-dev.2                            
npm notice filename:      remix-pwa-dev-2.0.26-dev.2.tgz

Creating a stable release soon enough, then releasing a new remix-pwa version 👍

image Soon enough 😄

I just realized remix-pwa build is not producing public/entry.worker.js on macOS, either. So this particular aspect isn’t Windows specific. (I hadn’t tried it again since remix-pwa dev was fixed on Windows.)

Fix coming out soon

I just realized remix-pwa build is not producing public/entry.worker.js on macOS, either. So this particular aspect isn’t Windows specific. (I hadn’t tried it again since remix-pwa dev was fixed on Windows.)

Not a separate issue, updated remix-pwa to 3.0.16. Might want to test that, everything worked during gh actions run 😕

Nothin’. Just says Building Service Worker in production mode and exits, no public/entry.worker.js.

remix-pwa dev seems to work now! 🎉 Still not seeing the worker get output from remix-pwa build, though. I assumed they were related, but perhaps that’s a separate issue?

@remix-pwa/cache@2.0.10
@remix-pwa/strategy@2.1.7
@remix-pwa/sw@2.1.9
@remix-pwa/dev@2.0.27
@remix-pwa/worker-runtime@2.0.6
remix-pwa@3.0.15

Thanks. I give up, I am going to look for a windows pc to test this on in the meantime. Was entry.worker.js still getting built tho? If yes, delete it please

Sorry. 😔 And nah, entry.worker.js was never built.

Currently, I am not manually hunting and replacing slashes, Windows has an issue with path resolution when it comes to node and therefore, I have to create platform specific sophisticated methods to get them working. For example, the error above, somehow, all slashes got removed (I never use replace or replaceAll in the path algo), would look out for something I can use

Ah, okay - I was mainly referring to Patryk’s fixes.

Btw, pls are you using remix-pwa@3.0.12?

Yep.

My stack trace shows error at line 22

and changing the path to use resolveUrl fixes the error

- const workerConfig = (await import(findConfig(remixRoot, 'remix.config', EXTENSIONS) as string).then(
+ const workerConfig = (await import(resolveUrl(findConfig(remixRoot, 'remix.config', EXTENSIONS) as string)).then(

It was reading the .env of the project. I am sure that if you changed "build:worker": "remix-pwa build" script to "build:worker": "cross-env NODE_ENV=production remix-pwa build", it would build successfully. But I should be handling that under the hood myself, so a PR is in order!

That was quick! I was going open a second issue for this but ran out of time to gather more info. 😅 Nice find.