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

Attempt to fix importing URLs, #2358 #2374

Closed
wants to merge 1 commit into from
Closed

Attempt to fix importing URLs, #2358 #2374

wants to merge 1 commit into from

Conversation

dandv
Copy link
Contributor

@dandv dandv commented Dec 8, 2018

↪️ Pull Request

Followed @DeMoorJasper's advice in 2358. That fixes the error I was seeing at the CLI, but when I navigate to the local server, I see this error in the Chrome console:

test.e31bb0bc.js:39 Uncaught (in promise) Error: Cannot find module 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js'
at newRequire (test.e31bb0bc.js:39)
at newRequire (test.e31bb0bc.js:23)
at localRequire (test.e31bb0bc.js:55)
at bundle-loader.js:17

🚨 Test instructions

See #2358. Running the CLI succeeded, the browser failed.

image

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@@ -496,6 +497,8 @@ class Bundler extends EventEmitter {
}

async installDep(asset, dep) {
// Check if module is a URL, skip trying to resolve
if (isURL(dep.name)) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to check for there... the only value that's the absolute URL at that line seems to be node.callee.object.arguments[0].value, but if (isURL(node.callee.object.arguments[0].value)) return; causes a failure the next time that line executes:

$ node ./parcel-bundler/bin/cli.js index.html
Server running at http://localhost:1234
🚨 /home/dandv/prg/parcel/packages/core/index.js: Cannot read property 'arguments' of undefined
at CallExpression (/home/dandv/prg/parcel/packages/core/parcel-bundler/src/visitors/dependencies.js:56:34)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:149:9)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:186:9)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:186:9)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:186:9)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:183:11)
at c (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:186:9)
at Object.ancestor (/home/dandv/prg/parcel/node_modules/babylon-walk/lib/index.js:210:5)
at JSAsset.collectDependencies (/home/dandv/prg/parcel/packages/core/parcel-bundler/src/assets/JSAsset.js:82:10)
at JSAsset.getDependencies (/home/dandv/prg/parcel/packages/core/parcel-bundler/src/Asset.js:79:18)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2380 should work, Note that this implementation doesn't work in internet explorer and any other browser that does not support import() natively.

In the future it would be a good thing to process these through parcel's bundle loader as well

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

Successfully merging this pull request may close these issues.

None yet

2 participants