Skip to content

Commit

Permalink
wip: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swandir committed Apr 8, 2021
1 parent 0dc6e37 commit 0e078e4
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ test('dep w/ non-js files handled via plugin', async () => {
test('vue + vuex', async () => {
expect(await page.textContent('.vue')).toMatch(`[success]`)
})

test('dep borwser field per module', async () => {
expect(await page.textContent('.dep-browser-field-per-module')).toBe(
'browser'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './platform'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "dep-browser-field-per-module",
"version": "0.0.0",
"main": "index.js",
"browser": {
"./platform.js": "./platform.browser.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'browser'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'node'
11 changes: 11 additions & 0 deletions packages/playground/optimize-deps/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ <h2>Dedupe (dep in linked & optimized package)</h2>
<h2>CommonJS w/ browser field mapping (axios)</h2>
<div>This should show pong: <span class="cjs-browser-field"></span></div>

<h2>Optimizing deps with per module browser field override</h2>
<div>
This should show "browser": <span class="dep-browser-field-per-module"></span>
</div>

<h2>Detecting linked src package and optimizing its deps (lodash-es)</h2>
<div>This should show fooBarBaz: <span class="deps-linked"></span></div>

Expand Down Expand Up @@ -65,3 +70,9 @@ <h2>Vue & Vuex</h2>
document.querySelector('.vue').textContent = '[success]'
}
</script>

<script type="module">
import platform from 'dep-browser-field-per-module'

document.querySelector('.dep-browser-field-per-module').textContent = platform
</script>
1 change: 1 addition & 0 deletions packages/playground/optimize-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"axios": "^0.21.1",
"clipboard": "^2.0.6",
"dep-browser-field-per-module": "link:./dep-browser-field-per-module",
"dep-cjs-named-only": "link:./dep-cjs-named-only",
"dep-linked": "link:./dep-linked",
"dep-linked-include": "link:./dep-linked-include",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/optimize-deps/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
},

optimizeDeps: {
include: ['dep-linked-include'],
include: ['dep-linked-include', 'dep-browser-field-per-module'],
plugins: [vue()]
},

Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,10 @@ delegate@^3.1.2:
resolved "https://registry.yarnpkg.com/delegate/-/delegate-3.2.0.tgz#b66b71c3158522e8ab5744f720d8ca0c2af59166"
integrity sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==

"dep-browser-field-per-module@link:./packages/playground/optimize-deps/dep-browser-field-per-module":
version "0.0.0"
uid ""

"dep-cjs-named-only@link:./packages/playground/optimize-deps/dep-cjs-named-only":
version "0.0.0"
uid ""
Expand Down

0 comments on commit 0e078e4

Please sign in to comment.