From adb9c3190c4e51ca0821d59dc81a189b8cf20f28 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 5 Aug 2019 13:57:43 +0300 Subject: [PATCH] refactor: restore hmr for lazy styles after refactor --- src/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index d8c2dc55..09b477f1 100644 --- a/src/index.js +++ b/src/index.js @@ -66,7 +66,8 @@ if (module.hot) { var lastRefs = module.hot.data && module.hot.data.refs || 0; if (lastRefs) { - exports.ref(); + exports.use(); + if (!content.locals) { refs = lastRefs; } @@ -94,8 +95,13 @@ var options = ${JSON.stringify(options)}; options.insert = ${insert}; options.singleton = ${isSingleton}; -if (typeof content === 'string') content = [[module.id, content, '']]; -if (content.locals) exports.locals = content.locals; +if (typeof content === 'string') { + content = [[module.id, content, '']]; +} + +if (content.locals) { + exports.locals = content.locals; +} exports.use = function() { if (!(refs++)) { @@ -171,8 +177,6 @@ if (module.hot) { if (typeof content === 'string') content = [[module.id, content, '']]; -var insertInto; - var options = ${JSON.stringify(options)} options.insert = ${insert};