Skip to content

Commit

Permalink
test: add test for vitejs#294
Browse files Browse the repository at this point in the history
  • Loading branch information
csr632 committed May 29, 2020
1 parent 00a385a commit f4810b4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion playground/TestModuleResolve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<div class="dot-resolve" :class="dotResolve">
filename with dot resolve: {{ dotResolve }}
</div>
<div class="browser-field-resolve" :class="browserFieldResolve">
resolve browser field in package.json: {{ browserFieldResolve }}
</div>
</template>

<script>
Expand All @@ -25,6 +28,7 @@ import { add } from 'lodash-es'
import { test } from 'conditional-exports'
import { foo } from './util'
import { bar } from './util/bar.util'
import value from 'resolve-browser-field-test-package'
export default {
setup() {
Expand All @@ -34,7 +38,8 @@ export default {
optResolve: typeof add === 'function' ? 'ok' : 'error',
conditionalExports: test() ? 'ok' : 'error',
indexResolve: foo() ? 'ok' : 'error',
dotResolve: bar() ? 'ok' : 'error'
dotResolve: bar() ? 'ok' : 'error',
browserFieldResolve: value === 'success' ? 'ok' : 'error'
}
}
}
Expand Down
1 change: 1 addition & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lodash-es": "link:../node_modules/lodash-es",
"moment": "link:../node_modules/moment",
"rewrite-optimized-test-package": "link:./rewrite-optimized/test-package",
"resolve-browser-field-test-package": "link:./resolve-browser-field",
"conditional-exports": "link:./conditional-exports"
}
}
1 change: 1 addition & 0 deletions playground/resolve-browser-field/out/cjs.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'fail'
1 change: 1 addition & 0 deletions playground/resolve-browser-field/out/esm.browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'success'
9 changes: 9 additions & 0 deletions playground/resolve-browser-field/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "resolve-browser-field-test-package",
"version": "1.0.0",
"//": "real world example: https://github.com/axios/axios/blob/3f2ef030e001547eb06060499f8a2e3f002b5a14/package.json#L71-L73",
"main": "out/cjs.node.js",
"browser": {
"./out/cjs.node.js": "./out/esm.browser.js"
}
}
4 changes: 4 additions & 0 deletions playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
version "0.0.0"
uid ""

"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 ""
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('vite', () => {
expect(await getText('.module-resolve-conditional')).toMatch('ok')
expect(await getText('.index-resolve')).toMatch('ok')
expect(await getText('.dot-resolve')).toMatch('ok')
expect(await getText('.browser-field-resolve')).toMatch('ok')
})

if (!isBuild) {
Expand Down

0 comments on commit f4810b4

Please sign in to comment.