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

@swc/register fails with "Source map must be true, false or inline" #754

Closed
ecraig12345 opened this issue Apr 22, 2020 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@ecraig12345
Copy link

Describe the bug

When I try to use @swc/register on TypeScript code, even extremely simple code, it fails with the error:

/<project>/node_modules/@swc/core/index.js:121
        return super.transformSync(isModule ? JSON.stringify(src) : src, isModule, options);
                     ^

Error: internal error in Neon module: assertion failed: `(left == right)`
  left: `"both"`,
 right: `"inline"`: Source map must be true, false or inline
    at Compiler.transformSync (/<project>/node_modules/@swc/core/index.js:121:22)
    at Object.transformSync (/<project>/node_modules/@swc/core/index.js:189:21)
    at compile (/<project>/node_modules/@swc/register/lib/node.js:63:22)
    at compileHook (/<project>/node_modules/@swc/register/lib/node.js:78:16)
    at Module._compile (/<project>/node_modules/pirates/lib/index.js:93:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .ts] (/<project>/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

With some other config variants (besides the one shown below), I get a different error:

/<project>/node_modules/@swc/core/index.js:121
        return super.transformSync(isModule ? JSON.stringify(src) : src, isModule, options);
                     ^

Error: failed to process config file
    at Compiler.transformSync (/<project>/node_modules/@swc/core/index.js:121:22)
    at Object.transformSync (/<project>/node_modules/@swc/core/index.js:189:21)
    at compile (/<project>/node_modules/@swc/register/lib/node.js:63:22)
    at compileHook (/<project>/node_modules/@swc/register/lib/node.js:78:16)
    at Module._compile (/<project>/node_modules/pirates/lib/index.js:93:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/<project>/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

(Filed here instead of https://github.com/swc-project/register because it seems like issue tracking is centralized to this main repo right now?)

Input code
file.ts (similar errors if config is modified for JS code):

console.log('hi');

Run in console:

node -r '@swc/register' file.ts

Config
This was based on the samples in the documentation.

{
  "test": ".*.ts$",
  "module": {
    "type": "commonjs"
  }
}

Also happens if I add some jsc settings:

{
  "test": ".*.ts$",
  "module": {
    "type": "commonjs"
  },
  "jsc": {
    "parser": {
      "syntax": "typescript"
    }
  }
}

Expected behavior
The code is compiled and runs.

Version
@swc/core: 1.1.39
@swc/register: 0.1.6
Node 10.15.1
Mac OS 10.15.3

@kdy1 kdy1 added this to the v1.1.40 milestone May 1, 2020
@kdy1
Copy link
Member

kdy1 commented May 1, 2020

Fixed with @swc/register v0.1.7

@kdy1 kdy1 self-assigned this May 1, 2020
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 28, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants