Skip to content

Commit 83f1619

Browse files
committed
revert named exports support due to module format complexity
1 parent 0b77668 commit 83f1619

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

lib/loader.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,11 @@ module.exports = function (content) {
161161
}
162162

163163
var exports =
164-
'__vue_options__ = __vue_exports__ = ' +
165-
'__vue_exports__ || { default: {}, __esModule: true }\n' +
164+
'__vue_options__ = __vue_exports__ = __vue_exports__ || {}\n' +
166165
// ES6 modules interop
167-
'if (__vue_options__.__esModule) {\n' +
168-
' __vue_options__ = __vue_options__.default\n' +
169-
// Webpack 2 interop
170-
'} else if (typeof __vue_options__.default === "object") {\n' +
171-
' __vue_options__ = __vue_options__.default\n' +
172-
' __vue_exports__.__esModule = true\n' +
166+
'if (typeof __vue_exports__.default === "object") {\n' +
167+
(isProduction ? '' : 'if (Object.keys(__vue_exports__).length > 1) console.error("[vue-loader]: named exports are not supported.")\n') +
168+
'__vue_options__ = __vue_exports__ = __vue_exports__.default\n' +
173169
'}\n' +
174170
// constructor export interop
175171
'if (typeof __vue_options__ === "function") {\n' +
@@ -230,15 +226,15 @@ module.exports = function (content) {
230226
'")}\n'
231227
}
232228
// final export
233-
output += '\nmodule.exports = __vue_exports__ || __vue_options__\n'
229+
output += '\nmodule.exports = __vue_exports__\n'
234230
} else {
235231
// inject-loader support
236232
output +=
237233
'\n/* dependency injection */\n' +
238234
'module.exports = function (injections) {\n' +
239235
' __vue_exports__ = __vue_exports__(injections)\n' +
240236
exports +
241-
' return __vue_exports__ || __vue_options__\n' +
237+
' return __vue_exports__\n' +
242238
'}'
243239
}
244240

test/fixtures/basic.vue

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
</template>
44

55
<script>
6-
export function test () {
7-
return 'hi'
8-
}
9-
106
export default {
117
data () {
128
return {

test/test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ describe('vue-loader', function () {
7979
test({
8080
entry: './test/fixtures/basic.vue'
8181
}, function (window, module, rawModule) {
82-
// test named export
83-
expect(rawModule.test()).to.equal('hi')
8482
assertRenderFn(module, '<h2 class="red">{{msg}}</h2>')
8583
expect(module.data().msg).to.contain('Hello from Component A!')
8684
var style = window.document.querySelector('style').textContent
@@ -183,7 +181,7 @@ describe('vue-loader', function () {
183181
column: col
184182
})
185183
expect(pos.source.indexOf('basic.vue') > -1)
186-
expect(pos.line).to.equal(13)
184+
expect(pos.line).to.equal(9)
187185
done()
188186
})
189187
})

0 commit comments

Comments
 (0)