.babelrc
{
"presets": [
"env",
"stage-0"
]
}
package.json
"devDependencies": {
"babel-preset-env": "1.6.1",
"babel-preset-stage-0": "6.24.1",
"parcel-bundler": "1.4.1"
},
"scripts": {
"start": "parcel -p 3000 ./app/index.html"
}
failed when app/index.html contains non # hrefs, like
<nav>
<div class="grid-header nav-wrapper blue-grey lighten-1">
<a href="/" class="brand-logo"> Knockout.js</a>
<a href="/" data-activates="mobile-menu" class="button-collapse">
<i class="material-icons">menu</i>
</a>
<ul class="right hide-on-med-and-down">
<li><a href="/">Home</a></li>
<li><a href="/link1">Link 1</a></li>
<li><a href="/link2">Link 2</a></li>
</ul>
<ul class="side-nav" id="mobile-menu">
<li><a href="/">Home</a></li>
<li><a href="/link1">Login</a></li>
<li><a href="/link2">Logout</a></li>
</ul>
</div>
</nav>
error if index.html page contains <a href="/" ...>...</a>:
yarn start
yarn run v1.3.2
$ parcel -p 3000 ./app/index.html
Server running at http://localhost:3000
🚨 /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/app/index.html: Cannot resolve dependency './../../../../../../../../../..' at '/'
at /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
at load (/Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:166:21)
other info
yarn -v
1.3.2
node -v
v9.4.0
npm -v
5.6.0
uname -a
Darwin kostromin-mb.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
note: build works fine if replace all href="/.." to href="#/..."
Regards,
Maksim
Further to your note, I've noticed it still fails with href="/#/..."
@underscoredotspace yes, but I told that build wont fail if href starts with hash, but yours href="/#/..." starts form '/', not '#'
✨ It seems like parcel (1.5.0) has fixed this, here it is:
Virtualpaths, throw file not found error Details #487.
🚨 Here is what i think, maybe not correct.
In parcel (1.4.1), HTMLAsset may mistake virtual path for a dependency,
but in fact, this 'dependency' is not 'illegal',
then it console.error('Cannot resolve dependency')
So, if add this:
if (node.attrs) {
for (let attr in node.attrs) {
let elements = ATTRS[attr];
if (elements && elements.includes(node.tag)) {
let assetPath = this.addURLDependency(node.attrs[attr]);
/* patch */
if (node.tag === 'a' && node.attrs[attr].startsWith('/')) {
continue
}
if (!isURL(assetPath)) {
assetPath = urlJoin(this.options.publicURL, assetPath);
}
node.attrs[attr] = assetPath;
this.isAstDirty = true;
}
}
}
a[href='/'] can temporary work fine.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>#602</title>
</head>
<body>
<div id="app">
<a href="/"></a>
<a href="/home"></a>
<a href="/sidebar/foo"></a>
<a href="assets/harusame.jpg" style="display: block; width: 100px; height: 100px; background-color: rgba(9, 19, 39, .5)">Link to asset</a>
</div>
</body>
</html>
Before:
$ parcel irodorin.html
Server running at http://localhost:1234
⏳ Building...
Resolver line 17: resolved[0] E:\irodorin\irodorin\irodorin.html
⏳ Building irodorin.html...
Resolver line 17: resolved[0] E:\irodorin\irodorin\assets\harusame.jpg
⏳ Building harusame.jpg...
🚨 E:\irodorin\irodorin\irodorin.html: Cannot resolve dependency './..\..' at 'E:\'
...
...
After:
$ rm -rf .cache dist
$ parcel irodorin.html
Server running at http://localhost:1234
⏳ Building...
Resolver line 17: resolved[0] E:\irodorin\irodorin\irodorin.html
⏳ Building irodorin.html...
Resolver line 17: resolved[0] E:\irodorin\irodorin\assets\harusame.jpg
⏳ Building harusame.jpg...
✨ Built in 297ms.

As for a[href='#'], isUrl has filtered it:
I'm sorry that my english isn't good. :sob:
So is this completely fixed in the latest version?
I still have this issue in 1.5.1. The bundler probably shouldn't fail but rather give a warning and don't process the url or something. I just want to create a relative link to a resource hosted on the same domain but in another service via an nginx reverse proxy. E.g.
<a href="/otherservice/example.html">...</a>
Hello again,
I can confirm that 1.5.1 fixed my issue.
Thank you!
PS: @marcuslindfeldt I will close this, but if you still have trouble, probably it would be better to create new issue.
Regards,
Maksim
Most helpful comment
✨ It seems like parcel (1.5.0) has fixed this, here it is:
🚨 Here is what i think, maybe not correct.
In parcel (1.4.1), HTMLAsset may mistake virtual path for a dependency,
https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/assets/HTMLAsset.js#L42-L54
but in fact, this 'dependency' is not 'illegal',
then it
console.error('Cannot resolve dependency')So, if add this:
a[href='/']can temporary work fine.Example:
Before:
After:
As for
a[href='#'],isUrlhas filtered it:https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/assets/HTMLAsset.js#L47-L49
https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/utils/is-url.js#L3-L4
https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/utils/is-url.js#L8-L11
I'm sorry that my english isn't good. :sob: