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

[Bug]: width 3 given for non-narrow character error when building certain libraries #9075

Open
markmssd opened this issue Jan 21, 2025 · 3 comments
Assignees
Labels
bug Something isn't working upstream

Comments

@markmssd
Copy link

System Info

System:
OS: macOS 15.2
CPU: (10) arm64 Apple M1 Max
Memory: 211.67 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 7.28.0 - ~/Library/pnpm/pnpm
bun: 1.1.8 - ~/.bun/bin/bun
Browsers:
Brave Browser: 126.1.67.123
Chrome: 131.0.6778.265
Edge: 132.0.2957.115
Safari: 18.2
npmPackages:
@rspack/cli: ^1.1.8 => 1.2.0
@rspack/core: ^1.1.8 => 1.2.0

Details

When using the https://www.npmjs.com/package/@shopify/polaris-viz package, Rspack fails only when mode=production and devtool=source-map (see here).

I still couldn't figure out why it's happening (it wasn't happening with Rspack v1.1.8).

There's a somehow related issue with Rollup: rollup/rollup#5672. The error also seems to come from swc_common, and their fix seems to simply upgrade some unicode-related crates?

I created a repro in which I install this library, and import it in render.js.

Reproduce link

https://github.com/markmssd/rspack-repro/tree/rspack-1.2-error

Reproduce Steps

To reproduce:

git clone https://github.com/markmssd/rspack-repro/tree/rspack-1.2-error
npm i
npm run build:rspack

It will fail with

> [email protected] build:rspack
> cross-env RSPACK=1 rspack

Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
Message:  width 3 given for non-narrow character
Location: index.crates.io-6f17d22bba15001f/swc_common-5.0.0/src/syntax_pos.rs:714

Backtrace omitted.

Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
@markmssd markmssd added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jan 21, 2025
@chenjiahan chenjiahan added upstream and removed pending triage The issue/PR is currently untouched. labels Jan 26, 2025
@markmssd
Copy link
Author

I've tried with v1.2.2 too and the issue still persists.

@markmssd
Copy link
Author

markmssd commented Feb 4, 2025

I was able to narrow it down (and updated the reproducible) to the single character that's causing the issue.

In that @shopify/polaris-viz repo, there is this file: https://github.com/Shopify/polaris-viz/blob/main/packages/polaris-viz/src/data/character-widths.json, which contains tens of thousands of lines with all characters and their width. Only one of them causes an issue, which is .

FWIW, it has started failing since v1.2.0-alpha.0.

This character makes the build fail, even if it's in the file as a comment. Hopefully this will help fix the issue! (cc @GiveMe-A-Name since you got assigned to it 😄)

@GiveMe-A-Name
Copy link
Member

It seems a bug in swc. More detail follow swc-project/swc#10010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

3 participants