Skip to content

Commit f909eca

Browse files
jeremyzahnereddyerburgh
authored andcommitted
fix: support named exports (#55)
1 parent e047135 commit f909eca

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/process.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ module.exports = function (src, filePath) {
7979

8080
const map = generateSourceMap(script, '', filePath, scriptSrc, inputMap)
8181
let output = ';(function(){\n' + script + '\n})()\n' +
82-
'if (module.exports.__esModule) module.exports = module.exports.default\n' +
83-
'var __vue__options__ = (typeof module.exports === "function"' +
84-
'? module.exports.options' +
85-
': module.exports)\n'
82+
'var defaultExport = (module.exports.__esModule) ? module.exports.default : module.exports;' +
83+
'var __vue__options__ = (typeof defaultExport === "function"' +
84+
'? defaultExport.options' +
85+
': defaultExport)\n'
8686

8787
if (parts.template) {
8888
if (parts.template.src) {

test/NamedExport.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { randomExport } from './resources/NamedExport.vue'
2+
3+
describe('NamedExport', () => {
4+
it('exports named export "randomExport"', () => {
5+
expect(randomExport).toEqual(42)
6+
})
7+
})

test/resources/NamedExport.vue

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
export const randomExport = 42;
3+
4+
export default {
5+
name: 'NamedExport'
6+
}
7+
</script>

0 commit comments

Comments
 (0)