Skip to content

Commit

Permalink
feat: support node 14
Browse files Browse the repository at this point in the history
reverts 5b3c6e5
  • Loading branch information
sxzz committed Mar 6, 2024
1 parent a8b4bd2 commit af3b0ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"files": [
"dist"
],
"engines": {
"node": ">=14.0.0"
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch src",
Expand Down
6 changes: 3 additions & 3 deletions src/esbuild/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function getEsbuildPlugin<UserOptions = Record<string, never>>(
loader.onLoadCb = callback
},
onTransform(_options, callback) {
loader.options = loader.options || _options
loader.options ||= _options
loader.onTransformCb = callback
},
} as EsbuildPluginBuild)
Expand Down Expand Up @@ -100,11 +100,11 @@ export function getEsbuildPlugin<UserOptions = Record<string, never>>(
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,
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit af3b0ec

Please sign in to comment.