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

Syntax lowering bug #9990

Open
elsassph opened this issue Feb 4, 2025 · 1 comment
Open

Syntax lowering bug #9990

elsassph opened this issue Feb 4, 2025 · 1 comment
Labels

Comments

@elsassph
Copy link

elsassph commented Feb 4, 2025

Describe the bug

Having a bug when using syntax lowering with the stylis dependency - some imports aren't transformed correctly.

Input code

// stylis/Parser.js
import { from, /*...*/ } from './Utility.js'
import { char, /*...*/ } from './Tokenizer.js'

/*...*/
return node(value, root, parent, COMMENT, from(char()), /*...*/
/*...*/

Config

See rspack.config.mjs

function getSwcOptions(es5) {
  return es5 === "1"
    ? {
        isModule: "unknown",
        jsc: {
          externalHelpers: true,
        },
        env: {
          mode: "usage",
          coreJs: "3.40.0",
          target: "es2015",
        },
      }
    : undefined;
}

Playground link (or link to the minimal reproduction)

https://github.com/elsassph/rspack-repro-lowering-bug

SWC Info output

    Operating System:
        Platform: darwin
        Arch: arm64
        Machine Type: arm64
        Version: Darwin Kernel Version 24.2.0: Fri Dec  6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000
        CPU: (10 cores)
            Models: Apple M1 Pro

    Binaries:
        Node: 20.18.1
        npm: 10.8.2
        Yarn: N/A
        pnpm: 9.15.0

    Relevant Packages:
        @swc/core: N/A
        @swc/helpers: 0.5.15
        @swc/types: N/A
        

    SWC Config:
        output: N/A
        .swcrc path: N/A

    Next.js info:
        output: N/A

Expected behavior

Should compile from(char()) into

(0,_Utility_js__WEBPACK_IMPORTED_MODULE_1__.from)((0,_Tokenizer_js__WEBPACK_IMPORTED_MODULE_0__.char)())

Actual behavior

Incorrectly compile from(char()) into

(0,_Utility_js__WEBPACK_IMPORTED_MODULE_1__.from)(char())

e.g. the char() call isn't transformed - all other imports are correctly transformed.

Version

1.2.2

Additional context

Invoke test project as pnpm run dev:rspack:es5 to enable syntax lowering (crash in browser)
and compare with pnpm run dev:rspack to bundle without lowering (OK in browser)

@elsassph elsassph added the C-bug label Feb 4, 2025
@elsassph
Copy link
Author

elsassph commented Feb 4, 2025

Sorry maybe I should have raised that in RSpack project.

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