Skip to content

Commit 0409b3f

Browse files
authored
fix: add esbuild 0.21 to allowed range (#58)
1 parent c9481b3 commit 0409b3f

File tree

7 files changed

+428
-133
lines changed

7 files changed

+428
-133
lines changed

.github/workflows/node.js.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [16.x, 18.x, 20.x]
18+
node-version: [16.x, 18.x, 20.x, 22.x]
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2222

2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v1
24+
uses: actions/setup-node@v4
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727

2828
- name: Get yarn cache directory path
2929
id: yarn-cache-dir-path
3030
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
3131

32-
- uses: actions/cache@v2
32+
- uses: actions/cache@v4
3333
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
3434
with:
3535
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -43,5 +43,8 @@ jobs:
4343
- name: Build
4444
run: yarn workspace esbuild-node-externals build
4545

46-
- name: Test examples
46+
- name: Test unit
47+
run: yarn workspace esbuild-node-externals test
48+
49+
- name: Test examples (integration)
4750
run: yarn workspace example-basic build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66

77
# Build artefacts
88
dist
9+
temp

esbuild-node-externals/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"typecheck": "tsc --noEmit",
88
"prebuild": "rimraf ./dist",
99
"build": "tsc",
10-
"watch": "tsc --watch"
10+
"watch": "tsc --watch",
11+
"test": "node ./test/unit/index.test.mjs"
1112
},
1213
"repository": "https://github.com/pradel/esbuild-node-externals.git",
1314
"author": "Leo Pradel <[email protected]>",
@@ -30,11 +31,11 @@
3031
"tslib": "^2.4.1"
3132
},
3233
"peerDependencies": {
33-
"esbuild": "0.12 - 0.20"
34+
"esbuild": "0.12 - 0.21"
3435
},
3536
"devDependencies": {
3637
"@types/node": "^18.15.10",
37-
"esbuild": "^0.20.0",
38+
"esbuild": "^0.21.0",
3839
"rimraf": "^4.4.1",
3940
"typescript": "^4.9.4"
4041
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { __extends } from 'tslib'
2+
3+
console.log(__extends)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "fixture-pkg",
3+
"private": true,
4+
"dependencies": {
5+
"tslib": "*"
6+
}
7+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import assert from 'node:assert'
2+
import fs from 'node:fs/promises'
3+
import path from 'node:path'
4+
import { describe, it } from 'node:test'
5+
import { fileURLToPath } from 'node:url'
6+
import { build } from 'esbuild'
7+
import { nodeExternalsPlugin } from 'esbuild-node-externals'
8+
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
10+
11+
describe('nodeExternalsPlugin', () => {
12+
it('should exclude node_modules from bundle', async () => {
13+
const plugin = nodeExternalsPlugin()
14+
const config = {
15+
absWorkingDir: path.resolve(__dirname, '../fixtures'),
16+
entryPoints: ['index.mjs'],
17+
outdir: '../temp',
18+
bundle: true,
19+
}
20+
await build(config)
21+
const result1 = await fs.readFile(path.resolve(__dirname, '../temp/index.js'), 'utf8')
22+
assert.ok(result1.includes('node_modules/tslib/tslib.es6.mjs'), true)
23+
24+
await build({
25+
...config,
26+
plugins: [plugin]
27+
})
28+
assert.ok(result1.includes('node_modules/tslib/tslib.es6.mjs'), false)
29+
})
30+
})

0 commit comments

Comments
 (0)