Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempts to resolve unrelated string #592

Closed
wlib opened this issue Jan 20, 2018 · 2 comments
Closed

Attempts to resolve unrelated string #592

wlib opened this issue Jan 20, 2018 · 2 comments

Comments

@wlib
Copy link

wlib commented Jan 20, 2018

🐛 bug report - Attempts to resolve unrelated string

🎛 Configuration (cli command)

$ parcel build ./src/index.js

🤔 Expected Behavior

Parcel should not attempt to resolve random JS strings just because they look like paths.

😯 Current Behavior

File Structure:

/xyz/project/
  service-worker.js
  src/
    index.js

src/index.js:

if ("serviceWorker" in navigator) {
  addEventListener("load", () =>
    navigator.serviceWorker.register("/service-worker.js")
  );
}

Error:

$ parcel build ./src/index.js
🚨  /xyz/project/src/index.js: Cannot resolve dependency './../../../service-worker.js' at '/service-worker.js'
    at /xyz/project/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/xyz/project/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/xyz/project/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /xyz/project/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:166:21)

💁 Possible Solution

I have no idea, in another project with the same setup, this bug never hit me.

🌍 My Environment

Software Version(s)
Parcel 1.4.1
Node 9.2.1
Yarn 1.3.2
OS OS X Yosemite 10.10.5
@DeMoorJasper
Copy link
Member

U can use a relative path, or you could wait untill absolute paths get supported (It's not unrelated as the worker.js's code should end up in the dist folder like anything else...)
Duplicate of #86 and #336

@maksimsemenov
Copy link
Contributor

maksimsemenov commented Jul 22, 2018

I don't think this is a duplicate. The core issue is that parcel tries to resolve string that looks like file path when it shouldn't do it. It should leave this string as is.

I'm seeing this issue now. Is there any workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants