diff options
Diffstat (limited to 'integration/bunjs-only-snippets/transpiler.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/transpiler.test.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js index 3d2064f72..61024e400 100644 --- a/integration/bunjs-only-snippets/transpiler.test.js +++ b/integration/bunjs-only-snippets/transpiler.test.js @@ -629,6 +629,40 @@ describe("Bun.Transpiler", () => { ); }); + describe("Bun.js", () => { + it("require -> import.meta.require", () => { + expectBunPrinted_( + `export const foo = require('bar.node')`, + `export const foo = import.meta.require("bar.node")` + ); + }); + + it("require.resolve -> import.meta.resolveSync", () => { + expectBunPrinted_( + `export const foo = require.resolve('bar.node')`, + `export const foo = import.meta.resolveSync("bar.node")` + ); + }); + + it('require.resolve(path, {paths: ["blah"]}) -> import.meta.resolveSync', () => { + expectBunPrinted_( + `export const foo = require.resolve('bar.node', {paths: ["blah"]})`, + `export const foo = import.meta.resolveSync("bar.node", { paths: ["blah"] })` + ); + }); + }); + + describe("Browsers", () => { + it('require.resolve("my-module") -> "/resolved/my-module"', () => { + // the module resolver & linker doesn't run with Bun.Transpiler + // so in this test, it becomes the same path string + expectPrinted_( + `export const foo = require.resolve('my-module')`, + `export const foo = "my-module"` + ); + }); + }); + it("define", () => { expectPrinted_( `export default typeof user_undefined === 'undefined';`, |