Skip to content

Commit

Permalink
fix: add esbuild 0.21 to allowed range (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored May 7, 2024
1 parent c9481b3 commit 0409b3f
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 133 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

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

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

- name: Test examples
- name: Test unit
run: yarn workspace esbuild-node-externals test

- name: Test examples (integration)
run: yarn workspace example-basic build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules

# Build artefacts
dist
temp
7 changes: 4 additions & 3 deletions esbuild-node-externals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"typecheck": "tsc --noEmit",
"prebuild": "rimraf ./dist",
"build": "tsc",
"watch": "tsc --watch"
"watch": "tsc --watch",
"test": "node ./test/unit/index.test.mjs"
},
"repository": "https://github.com/pradel/esbuild-node-externals.git",
"author": "Leo Pradel <[email protected]>",
Expand All @@ -30,11 +31,11 @@
"tslib": "^2.4.1"
},
"peerDependencies": {
"esbuild": "0.12 - 0.20"
"esbuild": "0.12 - 0.21"
},
"devDependencies": {
"@types/node": "^18.15.10",
"esbuild": "^0.20.0",
"esbuild": "^0.21.0",
"rimraf": "^4.4.1",
"typescript": "^4.9.4"
}
Expand Down
3 changes: 3 additions & 0 deletions esbuild-node-externals/test/fixtures/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { __extends } from 'tslib'

console.log(__extends)
7 changes: 7 additions & 0 deletions esbuild-node-externals/test/fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "fixture-pkg",
"private": true,
"dependencies": {
"tslib": "*"
}
}
30 changes: 30 additions & 0 deletions esbuild-node-externals/test/unit/index.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import assert from 'node:assert'
import fs from 'node:fs/promises'
import path from 'node:path'
import { describe, it } from 'node:test'
import { fileURLToPath } from 'node:url'
import { build } from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

describe('nodeExternalsPlugin', () => {
it('should exclude node_modules from bundle', async () => {
const plugin = nodeExternalsPlugin()
const config = {
absWorkingDir: path.resolve(__dirname, '../fixtures'),
entryPoints: ['index.mjs'],
outdir: '../temp',
bundle: true,
}
await build(config)
const result1 = await fs.readFile(path.resolve(__dirname, '../temp/index.js'), 'utf8')
assert.ok(result1.includes('node_modules/tslib/tslib.es6.mjs'), true)

await build({
...config,
plugins: [plugin]
})
assert.ok(result1.includes('node_modules/tslib/tslib.es6.mjs'), false)
})
})
Loading

0 comments on commit 0409b3f

Please sign in to comment.