{
"name": "parcel-worker-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "parcel index.html --no-cache"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.8.1",
"parcel-plugin-custom-asset": "file:parcel-plugin-custom-asset"
},
"dependencies": {}
}
Start the server app without errors.
Parcel compile without problems but when I enter on localhost:1234 I'm seeing the error:
Uncaught ReferenceError: process is not defined
at Object.parcelRequire.4 (parcel-worker-error.e898f6f3.js:133)
at newRequire (parcel-worker-error.e898f6f3.js:48)
at parcelRequire.2 (parcel-worker-error.e898f6f3.js:75)
at parcel-worker-error.e898f6f3.js:101
Is not a solution but I think this kind of errors start with the new feature of custom workerfarm in 1.7.1 and maybe the solution is the PR #1235
So, this issue is happening when we use some plugin that is extending a custom asset from JSAsset. In the code sample, you can see a simple test.
https://github.com/tinchoz49/parcel-worker-error
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.8.1
| Node | 10
| npm/Yarn | npm 6
| Operating System | Manjaro xfce
Why are you extending JSAsset?
This is not really a recommended way of handling assets as it might break in updates (due to not being part of the public api).
I just wrote a recent write-up of how I wrote parcel-plugin-svelte which utilises the newest functions parcel offers to go around requiring JSAsset, might be interesting https://medium.com/@jasperdemoor/writing-a-parcel-plugin-3936271cbaaa
Hi @DeMoorJasper how are you?
Thanks for sharing the post, it's really good and something necessary to understand better how we can create plugins.
The thing is, I'm using JSAsset which extends from Asset to override the extension '.js' and to add more features or maybe we can call it, to add more transforms on top of the already JSAsset.
How can I apply the same idea of transforming a JS file (like browserify) without losing what JSAsset gives us?
@tinchoz49 what exactly do you want to override?
If you'd like to add an extension to js and it's standardised than it's probably a good idea to submit a PR here.
If you are trying to add a new language you should probably use generate and extend Asset as described in my post and used in all parcels internal Assets.
EDIT: I can't seem to reproduce this
For example with surplus you have to compile your jsx templates that are inside of JS files. There are already a loader for webpack, a transform for browserify and since I really like parcel I try to create a plugin for them: https://github.com/tinchoz49/parcel-plugin-surplus
Ow right, I haven't thought about that.
Yeah this will have to use extends JSAsset I guess.
But like i said I'm not able to reproduce it. Would be nice if you could debug it and pinpoint where this happens exactly, I don't really understand why process would ever be undefined though. (is this an in-browser error or one from the parcel cli?)
Yes, me too I don't understand why the process is undefined. At the begin, I thought it was the surplus compiler but then I tested it to just extending from JSAsset without adding custom things and it didn't work.
I don't know if this can help but until the version 1.7.0 the surplus plugin worked.
btw: Thanks for taking the time to fork the plugin and debug it.
I was getting the same error. I was building Parcel for the browser in watch mode but using my own express server to serve app. Parcel leaves this line var hostname = process.env.HMR_HOSTNAME || location.hostname; in the client bundle, I'm guessing because it handles the bundle itself in watch mode. If I build with watch mode disabled, error dissapears. Going to use Parcel middleware to see what happens
Fixed by #1587 ?
@DeMoorJasper I tried installing and using the branch but got this error Error: ENOENT: no such file or directory, open 'C:\Users\alidc\Code\rogue\node_modules\parcel-bundler\src\builtins\prelude2.min.js'
@alidcastano run ‘yarn build’ after cloning
Sent with GitHawk
Hey guys, I'm getting an error like this while using the master branch.

I have a worker called from a typescript file, and it's literally the first line of the generated file.

One of the things I note is that this code is generated for HMR, but I have --no-hmr activated. Not sure if this is intended behavior.
Any help for this fix, or should I create a different issue thread?
This has nothing to do with this bug, you're probably mis-using webworkers.
This bug was related to parcel itself which isn't being logged inside the console
I'll open up another issue.