Skip to content

Commit

Permalink
chore: remove patch file deps hack (#8138)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed May 12, 2022
1 parent 8220ee5 commit a8b22b6
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 60 deletions.
13 changes: 1 addition & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,7 @@ test('?raw import', async () => {

## Note on Test Dependencies

In many test cases we need to mock dependencies using `link:` and `file:` protocols (which are supported by package managers like `yarn` and `pnpm`). However, `pnpm` treats `link:` and `file:` the same way and always use symlinks. This can be undesirable in cases where we want the dependency to be actually copied into `node_modules`.

To work around this, playground packages that uses the `file:` protocol should also include the following `postinstall` script:

```jsonc
"scripts": {
//...
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
}
```

This script patches the dependencies using `file:` protocol to match the copying behavior instead of linking.
In many test cases we need to mock dependencies using `link:` and `file:` protocols. `pnpm` treats `link:` as symlinks and `file:` as hardlinks. To test dependencies as if they are copied into `node_modules`, use the `file:` protocol, other cases should use the `link:` protocol.

## Debug Logging

Expand Down
3 changes: 1 addition & 2 deletions playground/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview",
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
"preview": "vite preview"
},
"dependencies": {
"aliased-module": "file:./dir/module",
Expand Down
3 changes: 1 addition & 2 deletions playground/dynamic-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview",
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
"preview": "vite preview"
},
"dependencies": {
"pkg": "file:./pkg"
Expand Down
2 changes: 1 addition & 1 deletion playground/optimize-deps/nested-exclude/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"nested-include": "link:./nested-include"
"nested-include": "file:../nested-include"
}
}
3 changes: 1 addition & 2 deletions playground/optimize-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview",
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
"preview": "vite preview"
},
"dependencies": {
"axios": "^0.24.0",
Expand Down
3 changes: 1 addition & 2 deletions playground/optimize-missing-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "node server",
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
"dev": "node server"
},
"dependencies": {
"missing-dep": "file:./missing-dep"
Expand Down
5 changes: 4 additions & 1 deletion playground/ssr-deps/forwarded-export/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "forwarded-export",
"private": true,
"version": "0.0.0"
"version": "0.0.0",
"dependencies": {
"object-assigned-exports": "file:../object-assigned-exports"
}
}
3 changes: 1 addition & 2 deletions playground/ssr-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"scripts": {
"dev": "node server",
"serve": "cross-env NODE_ENV=production node server",
"debug": "node --inspect-brk server",
"postinstall": "ts-node ../../scripts/patchFileDeps.ts"
"debug": "node --inspect-brk server"
},
"dependencies": {
"bcrypt": "^5.0.1",
Expand Down
21 changes: 16 additions & 5 deletions pnpm-lock.yaml

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

31 changes: 0 additions & 31 deletions scripts/patchFileDeps.ts

This file was deleted.

0 comments on commit a8b22b6

Please sign in to comment.