Skip to content

Commit

Permalink
fix(vue-style-loader): use esm
Browse files Browse the repository at this point in the history
from: 8b584bd899d4adec9e7de783fe405e0a32171519, 8bc2fe3d85781ce6ba52c9fa17ea4f3424e59386
  • Loading branch information
zhetengbiji committed Aug 10, 2022
1 parent 881fe6a commit 9b45db6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;'
Expand Down Expand Up @@ -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);',
' });',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;'
Expand Down Expand Up @@ -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);',
' });',
Expand Down

0 comments on commit 9b45db6

Please sign in to comment.