Skip to content

Commit 18d0ae4

Browse files
committed
feat: use ESM for runtime files
1 parent 318a802 commit 18d0ae4

9 files changed

+2765
-2995
lines changed

Diff for: .babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["transform-es2015-modules-commonjs"]
3+
}

Diff for: index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module.exports.pitch = function (remainingRequest) {
4040
// on the client: dynamic inject + hot-reload
4141
var code = [
4242
'// add the styles to the DOM',
43-
'var update = require(' + addStylesClientPath + ')(' + id + ', content, ' + isProduction + ', ' + JSON.stringify(options) + ');'
43+
'var add = require(' + addStylesClientPath + ').default',
44+
'var update = add(' + id + ', content, ' + isProduction + ', ' + JSON.stringify(options) + ');'
4445
]
4546
if (!isProduction) {
4647
code = code.concat([
@@ -67,7 +68,7 @@ module.exports.pitch = function (remainingRequest) {
6768
// component's lifecycle hooks
6869
return shared.concat([
6970
'// add CSS to SSR context',
70-
'var add = require(' + addStylesServerPath + ')',
71+
'var add = require(' + addStylesServerPath + ').default',
7172
'module.exports.__inject__ = function (context) {',
7273
' add(' + id + ', content, ' + isProduction + ', context)',
7374
'};'

Diff for: lib/addStylesClient.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Modified by Evan You @yyx990803
55
*/
66

7+
import listToStyles from './listToStyles'
8+
79
var hasDocument = typeof document !== 'undefined'
810

911
if (typeof DEBUG !== 'undefined' && DEBUG) {
@@ -14,8 +16,6 @@ if (typeof DEBUG !== 'undefined' && DEBUG) {
1416
) }
1517
}
1618

17-
var listToStyles = require('./listToStyles')
18-
1919
/*
2020
type StyleObject = {
2121
id: number;
@@ -49,7 +49,7 @@ var ssrIdKey = 'data-vue-ssr-id'
4949
// tags it will allow on a page
5050
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
5151

52-
module.exports = function (parentId, list, _isProduction, _options) {
52+
export default function addStylesClient (parentId, list, _isProduction, _options) {
5353
isProduction = _isProduction
5454

5555
options = _options || {}

Diff for: lib/addStylesServer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var listToStyles = require('./listToStyles')
1+
import listToStyles from './listToStyles'
22

3-
module.exports = function (parentId, list, isProduction, context) {
3+
export default function addStylesServer (parentId, list, isProduction, context) {
44
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
55
context = __VUE_SSR_CONTEXT__
66
}

Diff for: lib/listToStyles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Translates the list format produced by css-loader into something
33
* easier to manipulate.
44
*/
5-
module.exports = function listToStyles (parentId, list) {
5+
export default function listToStyles (parentId, list) {
66
var styles = []
77
var newStyles = {}
88
for (var i = 0; i < list.length; i++) {

0 commit comments

Comments
 (0)