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

Template Literals + prepend doesn't work correctly and results in invalid JS build #143

Open
patocallaghan opened this issue Dec 8, 2020 · 1 comment

Comments

@patocallaghan
Copy link

patocallaghan commented Dec 8, 2020

Take the example code below:

class Application {
  foo() {
    return bar(`${this.path}/application.js`);
  }
}

The particular line of interest is where we have a template literal.

return bar(`${this.path}/application.js`);

When we try to fingerprint this template literal string with some prepend URL it causes invalid JavaScript to be generated in the output.

{
  extensions: ['js', 'json', 'css', 'png', 'jpg', 'gif', 'map'],
  prepend: 'https://static.assets.com/ember/'
}

Expected

return bar(`https://static.assets.com/ember/${this.path}/application.js`);

Actual

return bar(https://static.assets.com/ember/`${this.path}/application.js`);

Notice the backtick to start the prepended string is at the end and not at the start of the fingerprint. This causes the JS to blow up when loaded in a browser.

Reproduction:

PR with failing test

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

No branches or pull requests

1 participant