Skip to content

Commit 284487e

Browse files
authored
ci: run tests with native resolver (#163)
1 parent e226aaa commit 284487e

File tree

3 files changed

+94
-14
lines changed

3 files changed

+94
-14
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,78 @@ jobs:
143143
steps:
144144
- run: echo "Build & Test Failed"
145145

146+
test-native-plugins:
147+
needs: changed
148+
if: needs.changed.outputs.should_skip != 'true'
149+
timeout-minutes: 20
150+
runs-on: ${{ matrix.os }}
151+
strategy:
152+
matrix:
153+
os: [ubuntu-latest, macos-latest, windows-latest]
154+
node_version: [22]
155+
fail-fast: false
156+
157+
name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (native plugins)"
158+
steps:
159+
- name: Checkout
160+
uses: actions/checkout@v4
161+
162+
- name: Install pnpm
163+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
164+
165+
- name: Set node version to ${{ matrix.node_version }}
166+
uses: actions/setup-node@v4
167+
with:
168+
node-version: ${{ matrix.node_version }}
169+
cache: "pnpm"
170+
171+
- name: Install deps
172+
run: pnpm install
173+
174+
# Install playwright's binary under custom directory to cache
175+
- name: (non-windows) Set Playwright path and Get playwright version
176+
if: runner.os != 'Windows'
177+
run: |
178+
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
179+
PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies["playwright-chromium"].version')"
180+
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
181+
- name: (windows) Set Playwright path and Get playwright version
182+
if: runner.os == 'Windows'
183+
run: |
184+
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
185+
$env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies["playwright-chromium"].version')"
186+
echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
187+
188+
- name: Cache Playwright's binary
189+
uses: actions/cache@v4
190+
with:
191+
key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }}
192+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
193+
restore-keys: |
194+
${{ runner.os }}-playwright-bin-v1-
195+
196+
- name: Install Playwright
197+
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
198+
run: pnpm playwright install chromium
199+
200+
- name: Build
201+
run: pnpm run build
202+
203+
- name: Test unit
204+
run: pnpm run test-unit
205+
env:
206+
_VITE_TEST_NATIVE_PLUGIN: 1
207+
208+
- name: Test serve
209+
run: pnpm run test-serve
210+
env:
211+
_VITE_TEST_NATIVE_PLUGIN: 1
212+
213+
- name: Test build
214+
run: pnpm run test-build
215+
env:
216+
_VITE_TEST_NATIVE_PLUGIN: 1
217+
146218
lint:
147219
timeout-minutes: 10
148220
runs-on: ubuntu-latest

packages/vite/src/node/__tests__/resolve.spec.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,22 @@ describe('file url', () => {
214214
expect(resolved).toBeNull()
215215
})
216216

217-
test('non declared node builtin', async () => {
218-
await expect(
219-
run({
220-
builtins: [
221-
/* empty */
222-
],
223-
idToResolve: 'node:fs',
224-
}),
225-
).rejects.toThrowError(
226-
/warning: Automatically externalized node built-in module "node:fs"/,
227-
)
228-
})
217+
// skip for native plugin because logs are not output (https://github.com/rolldown/rolldown/issues/4290)
218+
test.skipIf(!!process.env._VITE_TEST_NATIVE_PLUGIN)(
219+
'non declared node builtin',
220+
async () => {
221+
await expect(
222+
run({
223+
builtins: [
224+
/* empty */
225+
],
226+
idToResolve: 'node:fs',
227+
}),
228+
).rejects.toThrowError(
229+
/warning: Automatically externalized node built-in module "node:fs"/,
230+
)
231+
},
232+
)
229233

230234
test('default to node-like builtins', async () => {
231235
const resolved = await run({

packages/vite/src/node/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,9 @@ export const configDefaults = Object.freeze({
714714
renderBuiltUrl: undefined,
715715
hmrPartialAccept: false,
716716
skipSsrTransform: false,
717-
enableNativePlugin: false,
717+
enableNativePlugin: process.env._VITE_TEST_NATIVE_PLUGIN
718+
? 'resolver'
719+
: false,
718720
},
719721
future: {
720722
removePluginHookHandleHotUpdate: undefined,
@@ -1713,7 +1715,9 @@ export async function resolveConfig(
17131715
experimental: {
17141716
importGlobRestoreExtension: false,
17151717
hmrPartialAccept: false,
1716-
enableNativePlugin: false,
1718+
enableNativePlugin: process.env._VITE_TEST_NATIVE_PLUGIN
1719+
? 'resolver'
1720+
: false,
17171721
...config.experimental,
17181722
},
17191723
future: config.future,

0 commit comments

Comments
 (0)