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 href asset containing template syntax #1153

Closed
rodney757 opened this issue Apr 8, 2018 · 8 comments
Closed

attempts to resolve href asset containing template syntax #1153

rodney757 opened this issue Apr 8, 2018 · 8 comments
Labels
🐛 Bug Stale Inactive issues

Comments

@rodney757
Copy link

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
@devongovett
Copy link
Member

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

@rodney757
Copy link
Author

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

@edmorley
Copy link

edmorley commented May 10, 2018

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

@jisuo
Copy link

jisuo commented May 16, 2018

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

@DeMoorJasper
Copy link
Member

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.

@raymondborkowski
Copy link

raymondborkowski commented May 17, 2018

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

@DeMoorJasper
Copy link
Member

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

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Stale Inactive issues
Projects
None yet
Development

No branches or pull requests

7 participants