Skip to content

Commit

Permalink
Merge pull request #79 from davidmyersdev/74-fix-import-error
Browse files Browse the repository at this point in the history
Fix Buffer import error during Vite deps scan
  • Loading branch information
davidmyersdev committed Feb 9, 2024
2 parents b8193a2 + 4dc8421 commit a2ae151
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- run: pnpm build:core
- run: pnpm build:shims
- run: pnpm playwright install --with-deps
- run: pnpm -r test
- run: pnpm -r test:e2e
test-unit:
needs:
- install-dependencies
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: ./.github/actions/install-dependencies
- run: pnpm build:core
- run: pnpm build:shims
- run: pnpm test:build
- run: pnpm -r test
typecheck:
needs:
- install-dependencies
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"files.eol": "\n"
}
6 changes: 3 additions & 3 deletions examples/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"scripts": {
"build": "vite build",
"dev": "vite",
"test": "CI=true run-p test:build test:dev",
"test:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15174' WEB_SERVER_URL='http://localhost:15174' playwright test",
"test:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15173' WEB_SERVER_URL='http://localhost:15173' playwright test",
"test:e2e": "CI=true run-p test:e2e:*",
"test:e2e:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15174' WEB_SERVER_URL='http://localhost:15174' playwright test",
"test:e2e:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15173' WEB_SERVER_URL='http://localhost:15173' playwright test",
"typecheck": "tsc"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@
"build:types": "run-s typecheck",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "run-p test:build test:unit",
"test": "run-p test:build test:error-repros test:unit",
"test:build": "run-p test:build:*",
"test:build:react": "pnpm -C ./examples/react run build",
"test:build:vanilla": "pnpm -C ./examples/vanilla run build",
"test:build:vue": "pnpm -C ./examples/vue run build",
"test:dev:react": "pnpm -C ./examples/react run dev",
"test:dev:vanilla": "pnpm -C ./examples/vanilla run dev",
"test:dev:vue": "pnpm -C ./examples/vue run dev",
"test:error-repros": "run-p test:error-repros:*",
"test:error-repros:vite-scan-buffer-import-error": "pnpm --filter vite-scan-buffer-import-error test",
"test:unit": "vitest run --dir ./test",
"typecheck": "run-p typecheck:*",
"typecheck:core": "tsc",
Expand Down Expand Up @@ -111,7 +113,7 @@
"vite-plugin-externalize-deps": "^0.1.5",
"vite-plugin-inspect": "^0.7.42",
"vite-plugin-node-polyfills": "workspace:*",
"vitest": "^1.1.0"
"vitest": "^1.2.2"
},
"publishConfig": {
"access": "public"
Expand Down
143 changes: 107 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages:
- .
- './examples/*'
- './test/error-repros/*'
3 changes: 2 additions & 1 deletion shims/buffer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js"
"module": "./dist/index.js",
"browser": "./dist/index.js"
}
3 changes: 2 additions & 1 deletion shims/global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js"
"module": "./dist/index.js",
"browser": "./dist/index.js"
}
3 changes: 2 additions & 1 deletion shims/process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js"
"module": "./dist/index.js",
"browser": "./dist/index.js"
}
12 changes: 12 additions & 0 deletions test/error-repros/vite-scan-buffer-import-error/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-scan-buffer-import-error</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/test.ts"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions test/error-repros/vite-scan-buffer-import-error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "vite-scan-buffer-import-error",
"type": "module",
"private": true,
"scripts": {
"test": "vite optimize"
},
"devDependencies": {
"vite-plugin-node-polyfills": "workspace:*",
"vite@5.1.0": "npm:vite@5.1.0"
}
}
4 changes: 4 additions & 0 deletions test/error-repros/vite-scan-buffer-import-error/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Buffer } from 'node:buffer'

// eslint-disable-next-line no-console
console.log(Buffer.from('hello').toString())
10 changes: 10 additions & 0 deletions test/error-repros/vite-scan-buffer-import-error/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { nodePolyfills } from 'vite-plugin-node-polyfills'

export default {
optimizeDeps: {
force: true,
},
plugins: [
nodePolyfills(),
],
}

0 comments on commit a2ae151

Please sign in to comment.