swc icon indicating copy to clipboard operation
swc copied to clipboard

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

Open nartc opened this issue 4 years ago • 6 comments
trafficstars

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 avatar Oct 28 '21 21:10 nartc

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

lastmjs avatar Mar 10 '22 16:03 lastmjs

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.

JodiWarren avatar Mar 18 '22 15:03 JodiWarren

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

hungtcs avatar Jun 17 '22 07:06 hungtcs

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/[email protected]/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 https://github.com/evanw/esbuild/issues/619

MohamedLamineAllal avatar Aug 19 '22 10:08 MohamedLamineAllal

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

npearson72 avatar Oct 06 '22 14:10 npearson72

I still have this issue. Is there any known solution?

Edit by maintainers: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

ayervandyan avatar Jan 25 '24 13:01 ayervandyan