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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/parcel-bundler/src/Bundler.js
Expand Up @@ -20,6 +20,7 @@ const bundleReport = require('./utils/bundleReport');
const prettifyTime = require('./utils/prettifyTime');
const getRootDir = require('./utils/getRootDir');
const {glob} = require('./utils/glob');
const isURL = require('./utils/is-url');

/**
* The Bundler is the main entry point. It resolves and loads assets,
Expand Down Expand Up @@ -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

// Check if module exists, prevents useless installs
let resolved = await this.resolver.resolveModule(dep.name, asset.name);

Expand Down