parcel: optimizer-terser: Unterminated string constant bug
π bug report
Steps to reproduce:
- Add this in your
<script>
tag inindex.html
var SOLIDUS$1 = 0x002F; // U+002F SOLIDUS (/)
// '/*' .* '*/'
var Comment = {
}
-
run
parcel build index.html
-
Output:
Γ Build failed.
@parcel/optimizer-terser: Unterminated string constant
π€ Expected Behavior
Should build
π― Current Behavior
Build Fails
π Possible Solution
- Remove
// '/*' .* '*/'
from your code
π Your Environment
Software | Version(s) |
---|---|
Parcel | 2.0.0-beta.2 |
Node | v15.7.0 |
npm/Yarn | 7.4.3 |
Operating System | Windows 10 Pro 20H2 build:19042.928 |
Thanks
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (7 by maintainers)
Well, for me the problem was fixed, that way(i.e having code in a file). You seems to be already using a separate file, so I guess they need to fix this.
I ran into the
Unterminated string constant
today as well when trying runparcel build
on a project using thegraphql-tag
library for GraphQL queries.The interesting part is that
parcel serve
command builds the code and launches the dev server without any issues!I have the following code:
So, is this an issue in Parcel or Terser then?
I found the issue! I cloned the repo and did not have any issues either. I thought that was weird so I did a winmerge on the working and broken directory and found that the only difference was the line endings!. Linux EOL (LF) work, but Windows (CR+LF) break everything. When I committed the repo I had git setup to normalize EOL to LF.
I corrected the repo so it is now broken. I think the only thing that needs to change is in the src folder so attached are the broken files in case github normalizes them again for some reason (I had to change multiple settings to disable the EOL conversion on commit) crlf-eol.zip
same for me in beta 3.1
using
<script src="../src/index.js" type="module"></script>
it happens when I add faker and call it:
var faker = require("faker");
works with beta 1 and 2, though.
I am having the same issue with lit-element when the tagged templates have a new line (even if it is not the first character). All of my code is in its own TypeScript files (no HTML files at all since this project is a new JS lib).
Example:
results in
but this works fine (NOTE no new lines in template literal)
as does a normal template literal with new lines e.g.
Just like lanesawyer,
parcel serve
does not have this issue and everything works fine.Guess Iβll hijack your bug then since itβs the same error message even though you got around the problem π
No idea if itβs due to something funky that the
graphql-tag
library does or an underlying bug in the system, so weβll see!π€ I am including it using a script tag, like this:
<script type="module" src="./index.tsx"></script>