ember-cli / ember-cli/broccoli-asset-rev

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

Open
#143 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
86
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Take the example code below:

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

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

```js
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.

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

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

### Actual
```js
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](https://github.com/ember-cli/broccoli-asset-rev/pull/144)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.