Skip to content

Bun does not work with commonjs as expected #1968

@gera2ld

Description

@gera2ld

What version of Bun is running?

0.5.4

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

In a new directory, run the commands below:

$ bun init -y
$ bun add encoding-japanese

Change the content of index.ts to require('encoding-japanese').
Then run bun run index.ts.

What is the expected behavior?

No error.

What do you see instead?

An error occurred.

1 | exports.UTF8_TO_JIS_TABLE = require('./utf8-to-jis-table');
2 | exports.UTF8_TO_JISX0212_TABLE = require('./utf8-to-jisx0212-table');
3 | exports.JIS_TO_UTF8_TABLE = require('./jis-to-utf8-table');
           ^
TypeError: null is not an object (evaluating 'l[U]')
      at .../node_modules/encoding-japanese/src/encoding-table.js:3:8
      at .../node_modules/encoding-japanese/src/config.js:2:4
      at .../node_modules/encoding-japanese/src/index.js:1:4
      at .../index.ts:1:0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions