-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Unable to build
index.html
#8
Comments
Just got the same error, babel-preset-react-app, react, react-dom |
FWIW: I tried installing |
I think this is an issue with the minifier... uglify-js doesn't like non ES5 inputs. Will work on fixing that. In the mean time, you can disable the minifier with |
I also tried with babel-preset-minify and it just seemed to skip it: {
"name": "test-parcel",
"version": "1.0.0",
"scripts": {
"start": "parcel index.html",
"build": "cross-env NODE_ENV=production parcel build index.html --no-minify"
},
"devDependencies": {
"babel-preset-env": "^1.6.1",
"babel-preset-minify": "^0.2.0",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.1",
"parcel-bundler": "^1.0.1"
},
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"babel": {
"presets": [
"react",
"env"
],
"env": {
"production": {
"presets": [
"minify"
]
}
}
}
} |
amazing! thanks so much @devongovett |
Going to reopen to track this issue. |
Thanks for a great project @devongovett! FYI the Angular team fixed this same issue by using |
I can confirm that adding ⏳ Building index.html...
🚨 C:\dev\projects\parceljs\src\index.html: Unexpected token: operator (<)
at JS_Parse_Error.get (eval at <anonymous> (C:\dev\projects\parceljs\node_modules\htmlnano\node_modules\uglify-js\tools\node.js:27:1), <anonymous>:86:23)
at Logger.error (C:\dev\projects\parceljs\node_modules\parcel-bundler\src\Logger.js:69:22)
at Bundler.bundle (C:\dev\projects\parceljs\node_modules\parcel-bundler\src\Bundler.js:135:19)
at <anonymous> |
the issue come from the call to toEstree function from the babel-to-estree module. Two modules babel-types and babylon-walk are imported but never used. Look like something from the conception was forget to be developed. @devongovett or @thejameskyle can you explain what you were expecting in the uglify.js file ? |
I was giving a look into this issue. And maybe it is not related to uglify-js. At least in my tests. Like @pke I have noticed this error:
But it happens because the html used as example is not 100% correct
htmlnano which is used to minify the html also minifies script tags. Because the script tag is not closed it understands And about this error
it is throwed because babel-to-estree tries to get the loc info from the 'use strict' directive which is not always present, like when automatically added by babel. In this case I got it working by simple adding the 'use strict' directive in the top of the file. Because babel ignores it when it is already present. I will try to send a fix to babel-to-estree. About the html problem not sure if a validator should be added ... or if htmlnano has some option to make the parsing more strict. |
@davidnagli This had nothing to do with Uglify-JS, however #157 would fix it because it no longer uses babel-to-estree which caused the bug |
@DeMoorJasper Isn't #157 doing just that; it adds Uglify-ES |
@davidnagli It also removes babel-to-estree because ES6 is not supported when usin AST into Uglify, which fixes this bug |
Got it. Thanks for clearing that up :) |
This should be fixed, 0.0.3 just got released of babel-to-estree including the fix. |
I ran into this, so I'm just leaving a note here that if you're using yarn you may need to add this to your package.json to get the babel-to-estree fix:
|
Addition to comment above: You could also use the github version than it should use Uglify ES and babel generator and disregard babel-to-estree entirely |
I tried the same thing Somehow, the Here is my
.babelrc
Project structure:
any ideas on how to resolve, please help @devongovett, anyone? |
@zamhaq this bug has long been fixed please open up a new issue report. |
Please try this.
👉 the file path of js and css in dist/index.html are
👉 the file path of js and css in dist/index.html are |
I had the same problem but found out that it's actually due to my HTML. By changing |
This one's still happening for me with 1.6.2. Here's the error I get
|
@dumptyd update to 1.7.2 and open a new issue if you have an issue |
Happens in 1.8.1 too. However, it seems |
Because only production builds minify, as that takes a lot of time... @thosakwe |
Firstly, super excited for this. I was surprised at how quickly I was able to get a dev environment setup. You are doing some awesome work.
I have
parcel-bundler
,react
andreact-dom
installed.I have a simple
index.html
file and anindex.js
file which is just outputting "Hello World" to a new div on the index.html file.I have no problems running
parcel index.html
orparcel watch index.html
however when I run
parcel build index.html
I get the following error:Edit: Temporary workaround
The text was updated successfully, but these errors were encountered: