提交 9b45db6d 编写于 作者: Q qiang

fix(vue-style-loader): use esm

from: 8b584bd899d4adec9e7de783fe405e0a32171519, 8bc2fe3d85781ce6ba52c9fa17ea4f3424e59386
上级 881fe6af
......@@ -36,6 +36,8 @@ module.exports.pitch = function (remainingRequest) {
'',
'// load the styles',
'var content = require(' + request + ');',
// get default export if list is an ES Module (CSS Loader v4+)
"if(content.__esModule) content = content.default;",
// content list format is [id, css, media, sourceMap]
"if(typeof content === 'string') content = [[module.id, content, '']];",
'if(content.locals) module.exports = content.locals;'
......@@ -66,6 +68,7 @@ module.exports.pitch = function (remainingRequest) {
' if(!content.locals) {',
' module.hot.accept(' + request + ', function() {',
' var newContent = require(' + request + ');',
' if(newContent.__esModule) newContent = newContent.default;',
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
' update(newContent);',
' });',
......
......@@ -36,6 +36,8 @@ module.exports.pitch = function (remainingRequest) {
'',
'// load the styles',
'var content = require(' + request + ');',
// get default export if list is an ES Module (CSS Loader v4+)
"if(content.__esModule) content = content.default;",
// content list format is [id, css, media, sourceMap]
"if(typeof content === 'string') content = [[module.id, content, '']];",
'if(content.locals) module.exports = content.locals;'
......@@ -66,6 +68,7 @@ module.exports.pitch = function (remainingRequest) {
' if(!content.locals) {',
' module.hot.accept(' + request + ', function() {',
' var newContent = require(' + request + ');',
' if(newContent.__esModule) newContent = newContent.default;',
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
' update(newContent);',
' });',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册