diff --git a/eslint.config.js b/eslint.config.js index d4e4bdb5..2159edfc 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -20,4 +20,11 @@ module.exports = antfu( 'unicorn/prefer-node-protocol': 'off', }, }, + { + files: ['**/src/**/*.ts'], + rules: { + 'node/no-unsupported-features/node-builtins': 'error', + 'node/no-unsupported-features/es-builtins': 'error', + }, + }, ) diff --git a/package.json b/package.json index 828dcb6e..37b1c363 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,9 @@ "files": [ "dist" ], + "engines": { + "node": ">=14.0.0" + }, "scripts": { "build": "tsup", "dev": "tsup --watch src", diff --git a/src/esbuild/index.ts b/src/esbuild/index.ts index d7b415e5..e55b5bf1 100644 --- a/src/esbuild/index.ts +++ b/src/esbuild/index.ts @@ -68,7 +68,7 @@ export function getEsbuildPlugin>( loader.onLoadCb = callback }, onTransform(_options, callback) { - loader.options = loader.options || _options + loader.options ||= _options loader.onTransformCb = callback }, } as EsbuildPluginBuild) @@ -100,11 +100,11 @@ export function getEsbuildPlugin>( continue if (onTransformCb) { - result = result || {} + result ||= {} // caution: 'utf8' assumes the input file is not in binary. // if you want your plugin handle binary files, make sure to // `plugin.load()` them first. - result.contents = result.contents || await fs.promises.readFile(args.path, 'utf8') + result.contents ||= await fs.promises.readFile(args.path, 'utf8') const _result = await onTransformCb({ ...result, diff --git a/tsup.config.ts b/tsup.config.ts index 0b6af70a..240a654e 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -5,7 +5,7 @@ export const tsup: Options = { sourcemap: false, clean: true, format: ['cjs', 'esm'], - target: 'node16.14', + target: 'node14', dts: true, shims: true, entry: [