diff --git a/napi/minify/index.js b/napi/minify/index.js index ca361d2c19125..5cf32665f310d 100644 --- a/napi/minify/index.js +++ b/napi/minify/index.js @@ -3,8 +3,9 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) +import { createRequire } from 'node:module' +const require = createRequire(import.meta.url) +const __dirname = new URL('.', import.meta.url).pathname const { readFileSync } = require('node:fs') let nativeBinding = null @@ -400,6 +401,6 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -module.exports = nativeBinding -module.exports.minify = nativeBinding.minify -module.exports.Severity = nativeBinding.Severity +const { minify, Severity } = nativeBinding +export { minify } +export { Severity } diff --git a/napi/minify/package.json b/napi/minify/package.json index 83d93733fcbf1..3f787be6e7ca0 100644 --- a/napi/minify/package.json +++ b/napi/minify/package.json @@ -1,11 +1,11 @@ { "name": "oxc-minify", "version": "0.82.3", - "type": "commonjs", + "type": "module", "main": "index.js", "browser": "browser.js", "scripts": { - "build-dev": "napi build --platform", + "build-dev": "napi build --esm --platform", "build-test": "pnpm run build-dev", "build": "pnpm run build-dev --features allocator --release", "postbuild-dev": "node patch.mjs", diff --git a/napi/transform/index.js b/napi/transform/index.js index 8f16c9fb35c0e..62f00ddd14493 100644 --- a/napi/transform/index.js +++ b/napi/transform/index.js @@ -3,8 +3,9 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) +import { createRequire } from 'node:module' +const require = createRequire(import.meta.url) +const __dirname = new URL('.', import.meta.url).pathname const { readFileSync } = require('node:fs') let nativeBinding = null @@ -400,9 +401,9 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -module.exports = nativeBinding -module.exports.Severity = nativeBinding.Severity -module.exports.HelperMode = nativeBinding.HelperMode -module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration -module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform -module.exports.transform = nativeBinding.transform +const { Severity, HelperMode, isolatedDeclaration, moduleRunnerTransform, transform } = nativeBinding +export { Severity } +export { HelperMode } +export { isolatedDeclaration } +export { moduleRunnerTransform } +export { transform } diff --git a/napi/transform/package.json b/napi/transform/package.json index 57fcd3cca7564..ec3bdcc68e75b 100644 --- a/napi/transform/package.json +++ b/napi/transform/package.json @@ -1,11 +1,11 @@ { "name": "oxc-transform", "version": "0.82.3", - "type": "commonjs", + "type": "module", "main": "index.js", "browser": "browser.js", "scripts": { - "build-dev": "napi build --platform", + "build-dev": "napi build --esm --platform", "build-test": "pnpm run build-dev", "build": "pnpm run build-dev --features allocator --release", "postbuild-dev": "node patch.mjs", diff --git a/napi/transform/test/id.test.ts b/napi/transform/test/id.test.ts index 8ac53a9a881c4..efa69575971a4 100644 --- a/napi/transform/test/id.test.ts +++ b/napi/transform/test/id.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import oxc from '../index'; +import { isolatedDeclaration } from '../index'; describe('isolated declaration', () => { const code = ` @@ -18,7 +18,7 @@ describe('isolated declaration', () => { `; it('matches output', () => { - const ret = oxc.isolatedDeclaration('test.ts', code, { sourcemap: true }); + const ret = isolatedDeclaration('test.ts', code, { sourcemap: true }); expect(ret).toMatchObject({ code: '/**\n' + '* jsdoc 1\n' +