I wanted to try out new tree shaking feature at 1.9.0 but the project don't build when I add that cli command.
{
"env": {
"production": {
"presets": ["env", "react", "flow"],
"plugins": [
"emotion",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
],
"transform-decorators-legacy",
"transform-class-properties",
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css"}]
]
},
"development": {
"presets": ["env", "react", "flow"],
"plugins": [
"emotion",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
],
"transform-decorators-legacy",
"transform-class-properties",
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css"}]
]
},
"test": {
"presets": ["env", "react", "flow"],
"plugins": [
"emotion",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
],
"transform-decorators-legacy",
"transform-class-properties"
]
}
}
}
It should build as when I use parcel build without this tree shaking command
It does not finish the build.
This is the error message:
Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null
I also included the error log file
I want to try out new features in Parcel.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.0
| Node | 8.11.1
| npm/Yarn | 6.0.0
| Operating System | Windows 10 x64
Could you show us the content of the file responsible for the error?
It gives the log below at the terminal. I don't understand which file it is from looking at this log. Can you help me spotting the file please
`C:\Users\HP\Desktop\HardwareWeb>yarn build
yarn run v1.5.1
$ npm run rm:build && cross-env NODE_ENV=production concurrently "npm run babel:build" "npm run parcel:build"
[email protected] rm:build C:\Users\HP\Desktop\HardwareWeb
rimraf build
[1]
[1] > [email protected] parcel:build C:\Users\HP\Desktop\HardwareWeb
[1] > parcel build src/index.html -d build/public --experimental-scope-hoisting
[1]
[0]
[0] > [email protected] babel:build C:\Users\HP\Desktop\HardwareWeb
[0] > babel src/server -d build
[0]
โ Building index.html...
src\server\api_router.js -> build\api_router.js
[0] src\server\database\database.js -> build\database\database.js
[0] src\server\database\db_content.js -> build\database\db_content.js
[0] src\server\database\db_playlist.js -> build\database\db_playlist.js
[0] src\server\database\db_screen.js -> build\database\db_screen.js
โ Building index.js...
src\server\database\models.js -> build\database\models.js
[0] src\server\express.js -> build\express.js
ร Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null
at Object.validate (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-types\lib\definitions\index.js:109:13)
[1] at Object.validate (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-types\lib\index.js:505:9)
[1] at NodePath._replaceWith (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\replacement.js:176:7)
[1] at NodePath._remove (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\removal.js:58:10)
[1] at NodePath.remove (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\removal.js:30:8)
[1] at binding.referencePaths.concat.forEach.path (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:41:22)
[1] at Array.forEach (
[1] at Object.keys.forEach.name (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:32:10)
[1] at Array.forEach (
[1] at treeShake (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:20:33)
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! [email protected] parcel:build: parcel build src/index.html -d build/public --experimental-scope-hoisting
[1] npm ERR! Exit status 1
[1] npm ERR!
npm ERR! Failed at the [email protected] parcel:build script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2018-06-15T09_49_40_650Z-debug.log
[1] npm run parcel:build exited with code 1
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /d /s /c npm run rm:build && cross-env NODE_ENV=production concurrently \"npm run babel:build\" \"npm run parcel:build\"
Directory: C:\Users\HP\Desktop\HardwareWeb
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "C:\Users\HP\Desktop\HardwareWeb\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
`
I executed only the parcel command for an isolated log. Here it is below
C:\Users\HP\Desktop\HardwareWeb>yarn parcel:build
yarn run v1.5.1
$ parcel build src/index.html -d build/public --experimental-scope-hoisting
ร Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null
at Object.validate (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-types\lib\definitions\index.js:109:13)
at Object.validate (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-types\lib\index.js:505:9)
at NodePath._replaceWith (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\replacement.js:176:7)
at NodePath._remove (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\removal.js:58:10)
at NodePath.remove (C:\Users\HP\Desktop\HardwareWeb\node_modules\babel-traverse\lib\path\removal.js:30:8)
at binding.referencePaths.concat.forEach.path (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:41:22)
at Array.forEach (<anonymous>)
at Object.keys.forEach.name (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:32:10)
at Array.forEach (<anonymous>)
at treeShake (C:\Users\HP\Desktop\HardwareWeb\node_modules\parcel-bundler\src\scope-hoisting\shake.js:20:33)
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: C:\\WINDOWS\\system32\\cmd.exe
Arguments: /d /s /c parcel build src/index.html -d build/public --experimental-scope-hoisting
Directory: C:\\Users\\HP\\Desktop\\HardwareWeb
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\HP\\Desktop\\HardwareWeb\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@fathyb
I can build but browser complains of undefined variable which looks like the bundled output here: https://medium.com/@devongovett/parcel-v1-9-0-tree-shaking-2x-faster-watcher-and-more-87f2e1a70f79
parcel build --experimental-scope-hoisting client/scripts/index.js --public-url /
Builds fine. Start the server and navigate to home page:
Uncaught ReferenceError: $37$exports is not defined
I opened dev tools and searched for $37$exports in the bundled file and there is just one usage without a declaration.
[Production builds]
I get the same AssignmentExpression error.
Added a console.log to shake.js to output the 'path' which was triggering the error in parent.remove() call.
Please output a summary of the node/file with the error.
In my case this declaration was tripping up babel (?)
var isInDisabledFieldset = function isInDisabledFieldset(inst) {
var node;
try {
node = (0, _reactDom.findDOMNode)(inst);
} catch (err) {
/* ignore */
}
return !!node && (0, _matches.default)(node, 'fieldset[disabled] *');
};
I changed to below which fixed it.
var isInDisabledFieldset = function(inst) {
var node;
try {
node = (0, _reactDom.findDOMNode)(inst);
} catch (err) {
/* ignore */
}
return !!node && (0, _matches.default)(node, 'fieldset[disabled] *');
};
Then I got a different error in a different stage of tree shaking saying an ES6 file didn't have a 'default' node - that file definitely has an 'export default ABC'
I then removed the scope hoisting flag and found my index.html wasn't get overwritten even though the primary './src/index.js' reference was changing in builds.
At that stage I reverted to 1.8.1
Thanks @sujith97 and @TimNZ for reporting, could you open a dedicated issue for your bugs? It's very hard to keep track of tree-shaking issues otherwise. It's the most experimental feature of Parcel but it can get stable very quick if we get triage right.
Ah and @TimNZ if you're having issues unrelated the --experimental-scope-hoisting flag (index.html doesn't get overwritten) please also open an issue for it so we can fix this ASAP.
@fathyb Thanks for the response. Here is the ticket: Issue 1552
@fathyb Hi, was my logs good enough for you? Do you need me to do anything?
@fathyb thanks.
I'll wait till at least 1.9.1.
I've got a large React code base and there's a few issues that will be a mix of Parcel and Babel, and need someone a lot more capable than me sorting them.
Includes isolated cases of array destructuring and anon functions slipping through into production builds when I am targeting stage 0, dynamic imports breaking nested require, and others.
Thanks all, @hakankaraduman I pushed #1575 to fix it.
Released in v1.9.3.
Most helpful comment
Thanks all, @hakankaraduman I pushed #1575 to fix it.