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

node_modules can behave as partly not excluded #7325

Open
pp0rtal opened this issue Apr 24, 2023 · 1 comment
Open

node_modules can behave as partly not excluded #7325

pp0rtal opened this issue Apr 24, 2023 · 1 comment
Labels

Comments

@pp0rtal
Copy link

pp0rtal commented Apr 24, 2023

Describe the bug

Even if I put node_modules in the exclude (doc) config list, it can behave inconsistently:

As I need to install packages, I can't give an example on the playground.
However, I hosted a minimal example with every step to reproduce it in local.

Input code

./backend/node_modules/.bin/swc ./backend/ --out-dir ./backend_dist

Config

{
  "exclude": [
    "excluded_file",
    "node_modules"
  ]
}

Playground link

https://github.com/pp0rtal/swc-bug-node_modules-interfer
(See readme to reproduce in seconds on your machine)

Expected behavior

Successfully compiled: 1 file with swc (63.37ms)

Actual behavior

failed to load file

Caused by:
    stream did not contain valid UTF-8
failed to load file

Caused by:
    stream did not contain valid UTF-8
Successfully compiled: 1 file with swc (70.04ms)
Failed to compile 2 files with swc.
Error: Failed to compile:
backend/node_modules/map-or-similar/map-or-similar.min.gzip.js
backend/node_modules/memoizerific/memoizerific.min.gzip.js
    at initialCompilation (/swc-bug-node_modules-interfer/backend/node_modules/@swc/cli/lib/swc/dir.js:163:19)
    at async dir (/swc-bug-node_modules-interfer/backend/node_modules/@swc/cli/lib/swc/dir.js:228:5)
# exited with code 1

Version

1.3.53

Additional context

I chose memoizerific package to make swc fail, but it can happen with other packages.
Also, I noted that node_modules don't behave as excluded and impact significantly performances.

Interesting note: If I remove node_module from the exclude list, I have way more errors. It demonstrates that swc ignores most of node_modules files, but not everything. The error is not my .swcrc exclude list config.

Tasks

No tasks being tracked yet.
@pp0rtal
Copy link
Author

pp0rtal commented May 15, 2023

Similar issue in swc-cli project swc-project/cli#80
But maybe it's more core, not sure

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

No branches or pull requests

1 participant