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

Spack: "not processed by tsc resolver because base module is in node_modules" #2574

Open
nartc opened this issue Oct 28, 2021 · 6 comments
Open
Labels

Comments

@nartc
Copy link

nartc commented Oct 28, 2021

Describe the bug
spack cannot finish compiling with the following error:

(node:55412) UnhandledPromiseRejectionWarning: Error: load_transformed failed

Caused by:
    0: failed to analyze module
    1: failed to resolve @nestjs/websockets/socket-module from /Users/ctran/code/sandbox/test-nest-swc/node_modules/@nestjs/core/nest-application.js
    2: not processed by tsc resolver because base module is in node_modules
    3: index not found

Input code
reproduce repo: https://github.com/nartc/nest-swc-reproduce

  • Run yarn
  • Execute spack with --config pointing to spack.config.js

Config

{
  "jsc": {
    "target": "es2017",
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": true
    },
    "transform": {
      "decoratorMetadata": true,
      "legacyDecorator": true
    },
    "keepClassNames": true,
    "externalHelpers": true,
    "loose": true
  },
  "module": {
    "type": "commonjs",
    "strict": true,
    "noInterop": true
  }
}

Expected behavior
Spack should finish successfully

Version
The version of @swc/core: 1.2.105

Additional Context

Running swc src -d dist works. So I'm not sure what's going on here. I expect spack to behave somewhat similar to swc given similar configurations

@nartc nartc added the C-bug label Oct 28, 2021
@lastmjs
Copy link

lastmjs commented Mar 10, 2022

I am running into a similar issue, can you suggest a workaround?

@JodiWarren
Copy link

I have a similar issue:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: load_transformed failed

Caused by:
    0: failed to analyze module
    1: failed to resolve stream from <PATH_TO_PROJECT>/node_modules/styled-components/dist/styled-components.esm.js
    2: not processed by tsc resolver because base module is in node_modules
    3: index not found] {
  code: 'GenericFailure'
}

This is a package inside a yarn monorepo. Running swc on an individual package works perfectly.

@hungtcs
Copy link

hungtcs commented Jun 17, 2022

+1 Same issue when I want to use spack packing nestjs

@MohamedLamineAllal
Copy link
Contributor

MohamedLamineAllal commented Aug 19, 2022

Because of the esm/cjs and the trend that the packages are moving to esm. Providing a commonjs version of a module or library that import an esm only module. Require to transpile to commonjs the imported module from node_modules. Esbuild by default transpile and bundle node_modules modules. And u opt-out through --externals flag or option. And they allow using globs as well. swc should be capable of allowing the transpilation of node_modules packages.

Same error and issue.

[Error: load_transformed failed

Caused by:
   0: failed to analyze module
   1: failed to resolve node:http from /Users/mohamedlamineallal/repos/tsconfig-interface/node_modules/.pnpm/node-fetch@3.2.10/node_modules/node-fetch/src/index.js
   2: not processed by tsc resolver because base module is in node_modules
   3: Impossible to get the node_modules path] {
 code: 'GenericFailure'
}

In my case, the module is node-fetch that is esm only.

in jest for example the transformIgnorePattern with a value of node_modules\/(?!node-fetch) allow to handle that.

Same thing with webpack and exclude prop with same pattern.

Esbuild by default transpile unless u set packages to external evanw/esbuild#619

@npearson72
Copy link

Having the same issue. No response to this issue in nearly a year. 😞

kachick added a commit to kachick/wait-other-jobs that referenced this issue Jan 16, 2023
@ayervandyan

This comment has been minimized.

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

7 participants