-
-
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
Incorrect js file extension with --no-scope-hoist #7813
Comments
What OS are you using? |
It's Windows. |
How many cores does your CPU have? Could you determine what this function returns for you?
e.g. by running
in the shell? |
Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz, 2808 Mhz, 10 Core(s), 20 Logical Processor(s) |
The problem is that when writing the bundles parcel/packages/core/core/src/requests/WriteBundleRequest.js Lines 253 to 256 in 80c728c
this rename here
isn't awaited but happens sometime afterwards asynchronously. (The whole handleClose callback is called late, it's not just the missing fs.rename callback)
But it doesn't happen at all if Parcel stops the process forcefully: parcel/packages/core/parcel/src/cli.js Line 259 in 80c728c
|
I am getting this error after upgrading to Here is the command I am running:
So I am seeing this error without
|
This bug occurs for me every time. A workaround is to manually fix the file names using a script after parcel is finished 😕 |
For anybody who needs it, here is a little script I am currently running after import globby from 'globby';
import invariant from 'tiny-invariant';
import { join } from 'path';
import { rename } from 'fs/promises';
// https://regexr.com/6ir3l
const regex = /^(?<correct>.*?)(?<broken>\.\d+)$/;
const distDirectory = join(process.cwd(), './dist');
// parcel bug is causing random digits to be appended to some filenames
// https://github.com/parcel-bundler/parcel/issues/7813
export async function fixParcelFilenames() {
const files: string[] = await globby(`*`, {
cwd: distDirectory,
});
for (let i = 0; i < files.length; i++) {
const file = files[i];
const match = regex.exec(file);
if (match?.groups?.broken) {
const correct = match?.groups?.correct;
invariant(correct, 'expected to have correct file capture group');
await rename(join(distDirectory, file), join(distDirectory, correct));
console.log('broken file', file);
console.log('renamed to', correct);
}
}
} |
When I got this, the output files were (often) empty, so renaming might not be enough. Commenting out this line worked for me parcel/packages/core/parcel/src/cli.js Line 259 in 80c728c
|
Node 13.14.0 is working correctly, the next version 14.0.0 has this behaviour. Something regarding the timing of the Potentially nodejs/node@e13a37e49d |
This is what I get by using the following build command:
parcel build --dist-dir build --no-scope-hoist
Notice the wrong js file name. In the compiled html I get:
<script src="/index.ce910175.js" defer>
So the js file name would go as expected at some point, but it won't get the correct file name when the build gets completed.
It's actually a TypeScript project with index.html + index.ts.
If I remove
--no-scope-hoist
the js file gets the correct extension. But I don't want hoist, I need to keep the original identifier names intact.[email protected]
The text was updated successfully, but these errors were encountered: