ember-cli / ember-cli/broccoli-asset-rewrite
Rewrite matching incorrect asset instances
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
Noticed the rewrite is replacing an instance of "style.css" where it shouldn't.
It happens with this piece of code:
(it's a dependency of my project, [prosemirror-view](https://github.com/ProseMirror/prosemirror-view/blob/8c9a7d25021ce8e99d03a63c7fb7033a524fd4db/src/viewdesc.ts#L1469))
```js
function iosHacks(dom) {
if (dom.nodeName == "UL" || dom.nodeName == "OL") {
var oldCSS = dom.style.cssText; // <- just this line
dom.style.cssText = oldCSS + "; list-style: square !important";
window.getComputedStyle(dom).listStyle;
dom.style.cssText = oldCSS;
}
}
```
In the pointed line, looks like the `"style.css"` part of the string is being matched and replaced with the fingerprinted one, ending up looking like this:
(for some reason, the other lines are not being matched and stay as they should)
```js
var oldCSS = dom.style-0d55b35826f83b7acaf51324d2f32623.cssText;
```
This not only changes the purpose of the code (it's a subtraction now) but also breaks the terser because it's bad js syntax (variable starts with a number) and get this error:
```
Build Error (TerserWriter)
Invalid syntax: 0d55b35826f83b7acaf51324d2f32623
```
---
Update: this seems to be happening after code minification. This is the same function as above but after:
```js
function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var n=e.style.cssText;e.style.cssText=n+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=n}}
```
The matcher [here](https://github.com/ember-cli/broccoli-asset-rewrite/blob/3f4cdea0284c1e5ade2e76c8a99c82776853e4c6/index.js#L126) for `assetPath="style.css"` seems to be matching with this part `e.style.cssText;e.style.cs` and then replaces the "style.css" part with "style-THEHASH.css"
Any workaround for this? I have no idea how all of this works this is the first time I dig this deep into broccoli and the ember build process.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.