Parcel: attempts to resolve href asset containing template syntax

Created on 8 Apr 2018  路  8Comments  路  Source: parcel-bundler/parcel

Choose one: is this a 馃悰 bug report or 馃檵 feature request?

bug report

馃 Expected Behavior

don't attempt to resolve href assets.

馃槸 Current Behavior

the following code in and html file fails the build:

<a href="{{ $ctrl.bioProjectLink }}" target="_blank">

error: Cannot resolve dependency './%7B%7B%20$ctrl.bioProjectLink%20%7D%7D'

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.7.0
| Node |
| npm/Yarn |
| Operating System |

Bug Stale

All 8 comments

Hmm, why is parcel running over your templates? Shouldn't you run them through a templating engine first?

this is an angularJS app, so the template engine is clientside

I am hitting this too.

This (valid client side) AngularJS template syntax is being interpreted as a literal resource:
https://github.com/mozilla/treeherder/blob/55654a1195335b08b92a84e10f65dcc1ec73d5d3/ui/plugins/pluginpanel.html#L53-L61

...resulting in:

脳  C:\...\treeherder\ui\plugins\pluginpanel.html: Cannot resolve dependency './{{::job_log_url.url}}' at 'C:\...\treeherder\ui\plugins\{{::job_log_url.url}}'
    at Resolver.resolve (C:\...\treeherder\node_modules\parcel-bundler\src\Resolver.js:70:17)

webpack's html-loader uses loader-utils.isUrlRequest() to determine whether the contents is resource to follow:
https://github.com/webpack-contrib/html-loader/blob/27026d2f0f5523ddea2a68272c4b58d5b69cffc0/index.js#L55

Perhaps Parcel could borrow the regex from it? See:
https://github.com/webpack/loader-utils/blob/67499ff3d13c13ef455ec0fede90b714fc16d787/lib/isUrlRequest.js#L4-L10

I'm presuming this would need to be added somewhere in:
https://github.com/parcel-bundler/parcel/blob/master/src/assets/HTMLAsset.js

@rodney757 Workaround (and recommended by angular official docs) is to use ng-href and not href when you use {{}} for the link

If ng-href fixes this issue I think it's safe to close this as we should endorse the best practices. Instead of fixing things that aren't actually broken.

I still have an issue with non angular framework.

Edit: We use templates in html and at run time, this templating engine replaces the html macros but parcel is attempting to resolve these at build time thus throwing the error. @DeMoorJasper

Being more specific or opening up an issue dedicated to your issue would be more helpfull @raymondborkowski

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

Was this page helpful?
0 / 5 - 0 ratings