Skip to content

Commit 7035e26

Browse files
committed
Add failing test for import error
1 parent b8193a2 commit 7035e26

File tree

10 files changed

+157
-44
lines changed

10 files changed

+157
-44
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- run: pnpm build:core
3030
- run: pnpm build:shims
3131
- run: pnpm playwright install --with-deps
32-
- run: pnpm -r test
32+
- run: pnpm -r test:e2e
3333
test-unit:
3434
needs:
3535
- install-dependencies
@@ -39,7 +39,7 @@ jobs:
3939
- uses: ./.github/actions/install-dependencies
4040
- run: pnpm build:core
4141
- run: pnpm build:shims
42-
- run: pnpm test:build
42+
- run: pnpm -r test
4343
typecheck:
4444
needs:
4545
- install-dependencies

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib"
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"files.eol": "\n"
34
}

examples/vanilla/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"scripts": {
55
"build": "vite build",
66
"dev": "vite",
7-
"test": "CI=true run-p test:build test:dev",
8-
"test:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15174' WEB_SERVER_URL='http://localhost:15174' playwright test",
9-
"test:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15173' WEB_SERVER_URL='http://localhost:15173' playwright test",
7+
"test:e2e": "CI=true run-p test:e2e:*",
8+
"test:e2e:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15174' WEB_SERVER_URL='http://localhost:15174' playwright test",
9+
"test:e2e:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15173' WEB_SERVER_URL='http://localhost:15173' playwright test",
1010
"typecheck": "tsc"
1111
},
1212
"devDependencies": {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@
7373
"build:types": "run-s typecheck",
7474
"lint": "eslint .",
7575
"lint:fix": "eslint --fix .",
76-
"test": "run-p test:build test:unit",
76+
"test": "run-p test:build test:error-repros test:unit",
7777
"test:build": "run-p test:build:*",
7878
"test:build:react": "pnpm -C ./examples/react run build",
7979
"test:build:vanilla": "pnpm -C ./examples/vanilla run build",
8080
"test:build:vue": "pnpm -C ./examples/vue run build",
8181
"test:dev:react": "pnpm -C ./examples/react run dev",
8282
"test:dev:vanilla": "pnpm -C ./examples/vanilla run dev",
8383
"test:dev:vue": "pnpm -C ./examples/vue run dev",
84+
"test:error-repros": "run-p test:error-repros:*",
85+
"test:error-repros:vite-scan-buffer-import-error": "pnpm --filter vite-scan-buffer-import-error test",
8486
"test:unit": "vitest run --dir ./test",
8587
"typecheck": "run-p typecheck:*",
8688
"typecheck:core": "tsc",
@@ -111,7 +113,7 @@
111113
"vite-plugin-externalize-deps": "^0.1.5",
112114
"vite-plugin-inspect": "^0.7.42",
113115
"vite-plugin-node-polyfills": "workspace:*",
114-
"vitest": "^1.1.0"
116+
"vitest": "^1.2.2"
115117
},
116118
"publishConfig": {
117119
"access": "public"

pnpm-lock.yaml

Lines changed: 107 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
packages:
22
- .
33
- './examples/*'
4+
- './test/error-repros/*'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>vite-scan-buffer-import-error</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/test.ts"></script>
11+
</body>
12+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "vite-scan-buffer-import-error",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"test": "vite optimize"
7+
},
8+
"devDependencies": {
9+
"vite-plugin-node-polyfills": "workspace:*",
10+
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Buffer } from 'node:buffer'
2+
3+
// eslint-disable-next-line no-console
4+
console.log(Buffer.from('hello').toString())
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
2+
3+
export default {
4+
optimizeDeps: {
5+
force: true,
6+
},
7+
plugins: [
8+
nodePolyfills(),
9+
],
10+
}

0 commit comments

Comments
 (0)