Closed patrickhulce closed 4 years ago
This is already fixed with the version on master. However, here are some changed that were needed:
babel.config.json
instead of babel.config.js
for better caching (added in Babel 7.7.0)main: "....js"
fails because Parcel tries to emit a library version to that path (but that is not possible with an html file) - this change fixes the error you get. The next version will say here:
browser
in targets because, again, this target name has a special meaning (a library for the browser)
So with this, parcel@next
works (though this might cause problems with server.js
):
diff --git packages/server/package.json packages/server/package.json
index fd59922..a3bf460 100644
--- packages/server/package.json
+++ packages/server/package.json
@@ -1,6 +1,5 @@
{
"name": "@lhci/server",
Thanks very much for the quick response!
running parcel on a html entrypoint with main: "....js" fails because Parcel tries to emit a library version to that path
Hm, is there a way around this? We have a legitimate main
export for other libraries to require('@lhci/server')
and start an express server, so we can't eliminate it. Parcel is just used to bundle the frontend assets before publishing which are then used by the regular commonjs code that is not processed by parcel.
I was afraid you were gonna ask that...
Currently not, though I might look into that tomorrow
I still get this error when I try building: Error: Got unexpected undefined
.
I tried removing "main": "index.js"
from package.json, tried changing it to index.html
, tried adding main: false
to targets and other fixes mentioned here. I am just building a normal React+TypeScript app for the browser. Watch mode works, but build fails:
package.json (simplified):
{
"main": "index.html",
"targets": {
"main": false,
"browser": {
"publicUrl": "./"
}
}
You want
{
"app": "dist/index.html", // <-- arbitrary name, just not main,browser,module,types
"targets": {
"app": {
"publicUrl": "./"
}
}
}
and then parcel build src/index.html
.
And maybe delete your cache 😬
In package.json
should it be dist/index.html
or src/index.html
? Is it the input index.html or output (built) index.html ? It makes less sense to have the output specified as main.
It just builds an index.html
and copies the favicon.ico
. The .js
and .css
files are missing and not included:
Bundling...
√ Built in 3.80s
dist\index.html 599 B 5ms
└── src\index.html 914 B 535ms
dist\favicon.9d6209bd.ico 365 B 1ms
└── src\favicon.ico 365 B 8ms
dist\version-3.HASH_REF_66e4fe8cf849a3a8766f679024347abe.js 67 B 0ms
└── src\index.html 67 B 535ms
dist\version-3.HASH_REF_ee35b87c1a0bfc51e2679f10a7e5f643.css 32 B 0ms
└── src\index.html 32 B 535ms
If I change "app" to "app": "src/index.html"
, I get the Got unexpected undefined
again.
I think it was because of the cache, after clearing the cache it builds but now I get this error: This experimental syntax requires enabling the parser plugin: 'classProperties'
.
Related: https://github.com/parcel-bundler/parcel/issues/2668 , but the fix mentioned there doesn't work.
For me, cleaning the cache fixed the issue. 😅
Dang it.. why am I getting this same problem a year after the issue was closed? I am using Parcel 2.0.1.
Parcel watch fails, with the undefined error. Parcel build completes.
Software | Version(s) |
---|---|
Parcel | 2.0.1 |
Node | 14.17.6 |
npm | 6.14.15 |
Operating System | Mac OS 11.6.1 |
Parcel watch gives me this:
Error: Got unexpected undefined
at nullthrows (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/nullthrows/nullthrows.js:7:15)
at prettyDiagnostic (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/utils/lib/prettyDiagnostic.js:100:181)
at writeDiagnostic (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/reporter-cli/lib/CLIReporter.js:207:45)
at _report (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/reporter-cli/lib/CLIReporter.js:151:13)
at Object.report (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/reporter-cli/lib/CLIReporter.js:265:12)
at ReporterRunner.report (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/core/lib/ReporterRunner.js:105:33)
at Parcel._build (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/core/lib/Parcel.js:464:34)
at async Parcel._startNextBuild (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/core/lib/Parcel.js:298:24)
at async PromiseQueue._runFn (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/utils/lib/PromiseQueue.js:88:7)
at async PromiseQueue._next (/Users/a3235181/projects/telehealth/telehealth-web-app/node_modules/@parcel/utils/lib/PromiseQueue.js:75:5)
My package json is this:
{
"name": "patienthub-telehealth",
"app": "dist/index.html",
"targets": {
"app": {
"publicUrl": "/"
}
},
"scripts": {
"build-watch": "parcel watch client/index.html",
"start-watch": "nodemon server/index.js",
"dev": "concurrently --kill-others \"npm run start-watch\" \"npm run build-watch\"",
"build": "parcel build client/index.html --no-source-maps",
"start": "npm run build && node server/index.js"
},
"author": "Peter Mumford",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/plugin-transform-runtime": "^7.15.8",
"@babel/runtime-corejs2": "^7.15.4",
"@parcel/transformer-sass": "^2.0.1",
"@parcel/transformer-vue": "^2.0.1",
"@vue/compiler-sfc": "^3.2.26",
"@vue/component-compiler-utils": "^3.2.2",
"concurrently": "^6.3.0",
"parcel": "^2.0.1",
"postcss": "^8.4.5"
},
"dependencies": {
"@azure/communication-calling": "^1.3.2-beta.1",
"@azure/communication-common": "^1.1.0",
"@azure/communication-identity": "^1.0.0",
"@azure/communication-signaling": "^1.0.0-beta.11",
"@popperjs/core": "^2.10.2",
"@progresskinvey/saml2js": "git+https://github.com/Kinvey/saml2js.git",
"axios": "^0.24.0",
"bootstrap": "^5.1.2",
"cookie-parser": "^1.4.5",
"detect-browser": "^5.2.1",
"detect.js": "^2.2.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"express-session": "1.17.1",
"img": "^3.0.3",
"keyv": "^4.0.4",
"network-speed": "^2.1.1",
"passport": "0.4.1",
"passport-saml": "1.3.3",
"useragent": "^2.3.0",
"vue": "^2.6.14",
"winston": "^3.3.3"
}
}
Update. This helped me solve my problem: https://github.com/parcel-bundler/parcel/issues/7395
I had multiple root elements in a Transition element in a Vue file. Parcel 1 and Vue 2 did not object to this.
Delete the parcel-cache folder. It worked for me thanks.
🐛 bug report
While testing out parcel v2 I ran into a fatal build error with an internal-looking failure.
🎛 Configuration (.babelrc, package.json, cli command)
CLI
parcel watch ./src/ui/index.html
package.json
babelrc
🤔 Expected Behavior
It builds the project or provides an error message as to what is wrong with my configuration.
😯 Current Behavior
It fails with an internal undefined error message.
🔦 Context
Trying to help test out parcel v2 :)
💻 Code Sample
https://github.com/GoogleChrome/lighthouse-ci/tree/parcelv2/packages/server
in repo root, run
yarn
and thenyarn build:watch
🌍 Your Environment