Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: module rewrite in unoptimized dep #344

Merged
merged 9 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
testPathIgnorePatterns: ['/playground/', '/node_modules/'],
watchPathIgnorePatterns: ['<rootDir>/temp']
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"ws": "^7.2.3"
},
"devDependencies": {
"@babel/runtime": "7.10.2",
"@pika/react": "^16.13.1",
"@pika/react-dom": "^16.13.1",
"@types/es-module-lexer": "^0.3.0",
Expand Down
8 changes: 7 additions & 1 deletion playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<TestRewriteOptimized />
<TestCustomBlocks />
<TestOptimizeLink />
<TestRewriteUnoptimized />
<TestNormalizePublicPath />
</template>

<script>
Expand All @@ -48,6 +50,8 @@ import TestRewriteOptimized from './rewrite-optimized/TestRewriteOptimized.vue'
import TestCssAtImport from './css-@import/TestCssAtImport.vue'
import TestCustomBlocks from './custom-blocks/TestCustomBlocks.vue'
import TestOptimizeLink from './optimize-linked/TestOptimizeLink.vue'
import TestRewriteUnoptimized from './rewrite-unoptimized/TestRewriteUnoptimized.vue'
import TestNormalizePublicPath from './TestNormalizePublicPath.vue'
export default {
data: () => ({
Expand All @@ -73,7 +77,9 @@ export default {
TestAsync: defineAsyncComponent(() => import('./TestAsync.vue')),
TestRewriteOptimized,
TestCustomBlocks,
TestOptimizeLink
TestOptimizeLink,
TestRewriteUnoptimized,
TestNormalizePublicPath
}
}
</script>
3 changes: 1 addition & 2 deletions playground/TestHmr/TestHmr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
<span
class="hmr-propagation-full-dynamic-self-accepting"
ref="dynamicDataOutlet"
>qux not loaded</span
>
>qux not loaded</span>
<button
class="hmr-propagation-full-dynamic-load-self-accepting"
@click="loadFullDynamicSelfAccepting()"
Expand Down
21 changes: 21 additions & 0 deletions playground/TestNormalizePublicPath.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<h2>TestNormalizePublicPath</h2>
<p class="normalize-public-path">{{ msg }}</p>
</template>

<script>
import slicedToArray from '@babel/runtime/helpers/esm/slicedToArray'

const iterable = (function* () {
yield 2
yield 4
yield 6
yield 8
})()

export default {
data: () => ({
msg: JSON.stringify(slicedToArray(iterable, 2))
})
}
</script>
4 changes: 3 additions & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"bootstrap": "link:../node_modules/bootstrap",
"lodash-es": "link:../node_modules/lodash-es",
"moment": "link:../node_modules/moment",
"@babel/runtime": "link:../node_modules/@babel/runtime",
"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",
"optimize-linked": "link:./optimize-linked"
"optimize-linked": "link:./optimize-linked",
"rewrite-unoptimized-test-package": "link:./rewrite-unoptimized/test-package"
}
}
12 changes: 12 additions & 0 deletions playground/rewrite-unoptimized/TestRewriteUnoptimized.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<h2>Test rewrite in optimized module</h2>
<p class="test-rewrite-in-unoptimized">{{ msg }}</p>
</template>

<script>
import value from 'rewrite-unoptimized-test-package'

export default {
data: () => ({ msg: value })
}
</script>
3 changes: 3 additions & 0 deletions playground/rewrite-unoptimized/test-package/es/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Item } from './nested'

export default Item
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 123
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Item } from './foo'
6 changes: 6 additions & 0 deletions playground/rewrite-unoptimized/test-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "rewrite-unoptimized-test-package",
"version": "1.0.0",
"main": "es/index.js",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: UserConfig = {
plugins: [jsPlugin],
vueCustomBlockTransforms: { i18n: i18nTransform },
optimizeDeps: {
exclude: ['bootstrap'],
exclude: ['bootstrap', 'rewrite-unoptimized-test-package'],
link: ['optimize-linked']
}
}
Expand Down
17 changes: 17 additions & 0 deletions playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
# yarn lockfile v1


"@babel/runtime@link:../node_modules/@babel/runtime":
version "0.0.0"
uid ""

"bootstrap@link:../node_modules/bootstrap":
version "0.0.0"
uid ""

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

"lodash-es@link:../node_modules/lodash-es":
version "0.0.0"
uid ""
Expand All @@ -22,10 +30,19 @@
version "0.0.0"
uid ""

regenerator-runtime@^0.13.4:
version "0.13.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==

"resolve-browser-field-test-package@link:./resolve-browser-field":
version "0.0.0"
uid ""

"rewrite-optimized-test-package@link:./rewrite-optimized/test-package":
version "0.0.0"
uid ""

"rewrite-unoptimized-test-package@link:./rewrite-unoptimized/test-package":
version "0.0.0"
uid ""
Loading