Skip to content
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

Watch mode writes to output twice when using relative paths #128

Open
earlAchromatic opened this issue Mar 26, 2022 · 0 comments
Open

Watch mode writes to output twice when using relative paths #128

earlAchromatic opened this issue Mar 26, 2022 · 0 comments

Comments

@earlAchromatic
Copy link

Describe the bug

When I run the command npx swc ./src/index.js -o ./dist/output.js --watch the output.js file contains the output as expected on the first compilation.

When I alter index.js and then save, the watch mode triggers a re-compile. This time, the file contains the output from the first compile, and the output from the altered file.

If I remove the relative paths and instead do this: npx swc src/index.js -o dist/output.js --watch the output contains only the current altered file's compilation as expected.

Note: I used directories here but the behaviour is the same if you are just compiling and outputting at the root level i.e. npx swc ./index.js -o ./output.js --watch

Expected Behaviour

--watch mode does not include any previous compilations and only includes compiled output from the current file save even when using relative paths in command.

index.js:

console.log('Speedy Web Compiler');

output.js:

console.log('Speedy Web Compiler');

Updated index.js and Save:

console.log('Speedy Web Compiler is speedy');

Updated output.js:

console.log('Speedy Web Compiler is speedy');

Actual Behaviour

--watch mode includes first compiled output in output.js when relative paths are used in the command.

index.js:

console.log('Speedy Web Compiler');

output.js:

console.log('Speedy Web Compiler');

Updated index.js and Save:

console.log('Speedy Web Compiler is speedy');

Updated output.js:

console.log('Speedy Web Compiler');

console.log('Speedy Web Compiler is speedy');

This is confusing because the documentation uses relative paths in the usage section so I would expect that they would work everywhere.

see: https://swc.rs/docs/usage/cli#usage

May be related to #99 but I thought the extra detail may be helpful for context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant