Skip to content

Commit

Permalink
feat: optimizeDeps.link
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 1, 2020
1 parent 6e06fcf commit 2615f52
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 97 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ environment:

install:
- ps: Install-Product node $env:nodejs_version x64
- yarn
- yarn --frozen-lockfile

test_script:
- git --version
Expand Down
5 changes: 4 additions & 1 deletion playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<TestAlias />
<TestTransform />
<TestRewriteOptimized />
<TestOptimizeLink />
</template>

<script>
Expand All @@ -44,6 +45,7 @@ import TestAlias from './TestAlias.vue'
import TestTransform from './TestTransform.vue'
import TestRewriteOptimized from "./rewrite-optimized/TestRewriteOptimized.vue";
import TestCssAtImport from './css-@import/TestCssAtImport.vue'
import TestOptimizeLink from './optimize-linked/TestOptimizeLink.vue'
export default {
data: () => ({
Expand All @@ -67,7 +69,8 @@ export default {
TestAlias,
TestTransform,
TestAsync: defineAsyncComponent(() => import('./TestAsync.vue')),
TestRewriteOptimized
TestRewriteOptimized,
TestOptimizeLink
}
}
</script>
18 changes: 18 additions & 0 deletions playground/optimize-linked/TestOptimizeLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<h2>Optimize Linked Dep</h2>
<p class="optimize-linked" :style="{ color: msg === 'ok' ? 'green' : 'red' }">
{{ msg }}
</p>
</template>

<script>
import { bar } from 'optimize-linked'
export default {
data() {
return {
msg: bar() === 'linked-dep' ? 'ok' : 'error'
}
}
}
</script>
5 changes: 5 additions & 0 deletions playground/optimize-linked/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { foo } from 'linked-dep'

export function bar() {
return foo()
}
3 changes: 3 additions & 0 deletions playground/optimize-linked/linked-dep/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { foo } from './other.js'

export { foo }
3 changes: 3 additions & 0 deletions playground/optimize-linked/linked-dep/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function foo() {
return 'linked-dep'
}
6 changes: 6 additions & 0 deletions playground/optimize-linked/linked-dep/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "linked-dep",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
9 changes: 9 additions & 0 deletions playground/optimize-linked/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "optimize-linked",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"linked-dep": "link:./linked-dep"
}
}
7 changes: 7 additions & 0 deletions playground/optimize-linked/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"linked-dep@link:./linked-dep":
version "0.0.0"
uid ""
3 changes: 2 additions & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"moment": "link:../node_modules/moment",
"normalize.css": "link:../node_modules/normalize.css",
"resolve-browser-field-test-package": "link:./resolve-browser-field",
"rewrite-optimized-test-package": "link:./rewrite-optimized/test-package"
"rewrite-optimized-test-package": "link:./rewrite-optimized/test-package",
"optimize-linked": "link:./optimize-linked"
}
}
3 changes: 2 additions & 1 deletion playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const config: UserConfig = {
serviceWorker: !!process.env.USE_SW,
plugins: [jsPlugin],
optimizeDeps: {
exclude: ['bootstrap']
exclude: ['bootstrap'],
link: ['optimize-linked']
}
}

Expand Down
4 changes: 4 additions & 0 deletions playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
version "0.0.0"
uid ""

"optimize-linked@link:./optimize-linked":
version "0.0.0"
uid ""

"resolve-browser-field-test-package@link:./resolve-browser-field":
version "0.0.0"
uid ""
Expand Down
4 changes: 3 additions & 1 deletion src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ async function updateModule(
const mod = hotModulesMap.get(id)
if (!mod) {
console.error(
`[vite] got js update notification but no client callback was registered. Something is wrong.`
`[vite] got js update notification for "${id}" but no client callback ` +
`was registered. Something is wrong.`
)
console.error(hotModulesMap)
return
}

Expand Down
Loading

0 comments on commit 2615f52

Please sign in to comment.