Skip to content

Commit bc49318

Browse files
authored
Update to latest Svelte-HMR (#179)
1 parent 97abbbd commit bc49318

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# svelte-loader changelog
22

3+
## Unreleased
4+
5+
* Update to latest `svelte-hmr` package fixing Webpack 4 support
6+
37
## 3.1.1
48

59
* Fix empty sourcesContent ([#177](https://github.com/sveltejs/svelte-loader/pull/177))

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { relative } = require('path');
22
const { getOptions } = require('loader-utils');
3-
const { makeHot } = require('./lib/make-hot.js');
3+
const { buildMakeHot } = require('./lib/make-hot.js');
44
const { compile, preprocess } = require('svelte/compiler');
55

66
function posixify(file) {
@@ -60,6 +60,7 @@ module.exports = function(source, map) {
6060

6161
if (options.hotReload && !isProduction && !isServer) {
6262
const hotOptions = { ...options.hotOptions };
63+
const makeHot = buildMakeHot(hotOptions);
6364
const id = JSON.stringify(relative(process.cwd(), compileOptions.filename));
6465
js.code = makeHot(id, js.code, hotOptions, compiled, source, compileOptions);
6566
}

lib/make-hot.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ const { createMakeHot } = require('svelte-hmr');
33

44
const hotApi = require.resolve('./hot-api.js');
55

6-
const makeHot = createMakeHot({
6+
const buildMakeHot = (hotOptions) => createMakeHot({
77
walk,
88
meta: 'module',
99
hotApi,
10+
hotOptions
1011
});
1112

12-
module.exports.makeHot = makeHot;
13+
module.exports.buildMakeHot = buildMakeHot;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"dependencies": {
1818
"loader-utils": "^2.0.0",
1919
"svelte-dev-helper": "^1.1.9",
20-
"svelte-hmr": "^0.12.3"
20+
"svelte-hmr": "^0.14.2"
2121
},
2222
"devDependencies": {
2323
"chai": "^4.2.0",

test/loader.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ describe('loader', () => {
292292
expect(err).not.to.exist;
293293

294294
expect(code).to.contain('module && module.hot');
295-
expect(code).not.to.contain('"noPreserveState":true');
295+
expect(code).not.to.contain('"preserveLocalState":true');
296296
},
297297
{ hotReload: true }
298298
)
@@ -306,12 +306,12 @@ describe('loader', () => {
306306
expect(err).not.to.exist;
307307

308308
expect(code).to.contain('module && module.hot');
309-
expect(code).to.contain('"noPreserveState":true');
309+
expect(code).to.contain('"preserveLocalState":true');
310310
},
311311
{
312312
hotReload: true,
313313
hotOptions: {
314-
noPreserveState: true
314+
preserveLocalState: true
315315
}
316316
}
317317
)

0 commit comments

Comments
 (0)