Skip to content

Commit d240805

Browse files
committed
fix: webpack tests (#414)
#413 got things working, now the tests pass too!
1 parent 7b2f285 commit d240805

25 files changed

+572
-881
lines changed

packages/svelte/test/__snapshots__/rollup.test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function callAll(fns) {
170170
}
171171
172172
function _mount(target, anchor) {
173-
this._fragment.m(target, anchor);
173+
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
174174
}
175175
176176
function _unmount() {
@@ -194,7 +194,7 @@ var proto = {
194194
195195
196196
197-
function create_main_fragment(state, component) {
197+
function create_main_fragment(component, state) {
198198
var div, h1, text_1, div_1, p, p_class_value;
199199
200200
return {
@@ -238,11 +238,11 @@ function Svelte(options) {
238238
init(this, options);
239239
this._state = assign({}, options.data);
240240
241-
this._fragment = create_main_fragment(this._state, this);
241+
this._fragment = create_main_fragment(this, this._state);
242242
243243
if (options.target) {
244244
this._fragment.c();
245-
this._fragment.m(options.target, options.anchor || null);
245+
this._mount(options.target, options.anchor);
246246
}
247247
}
248248

packages/webpack/loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ var utils = require("loader-utils"),
88
module.exports = function(source) {
99
var options = utils.getOptions(this) || false,
1010
done = this.async(),
11-
processor = this.options
12-
? this.options.processor // Webpack 2 & 3
13-
: this._compiler.options.processor; // Webpack 4
11+
processor = this.options ?
12+
this.options.processor : // Webpack 2 & 3
13+
this._compiler.options.processor; // Webpack 4
1414

1515
if(options.cjs) {
1616
this.emitWarning(

packages/webpack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"esutils": "^2.0.2",
2727
"loader-utils": "^1.1.0",
28+
"lodash.ismap": "^4.4.2",
2829
"modular-css-core": "^8.1.0",
2930
"webpack-sources": "^1.0.1"
3031
}

packages/webpack/plugin.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use strict";
22

33
var sources = require("webpack-sources"),
4-
Processor = require("modular-css-core");
4+
Processor = require("modular-css-core"),
5+
ismap = require("lodash.ismap");
56

67
// Return a list of changed/removed files based on timestamp objects
78
function getChangedFiles(prev, curr) {
@@ -36,7 +37,7 @@ ModularCSS.prototype.apply = function(compiler) {
3637
compiler.plugin("invalid", (file) => {
3738
this.processor.remove(file);
3839
});
39-
40+
4041
compiler.plugin("watch-run", (c, done) => {
4142
watching = true;
4243

@@ -53,7 +54,15 @@ ModularCSS.prototype.apply = function(compiler) {
5354
// This code is only useful when calling .run() multiple times
5455
// watching handles its own invalidations
5556
if(!watching) {
56-
files = getChangedFiles(this.prev, compilation.fileTimestamps);
57+
let current;
58+
59+
if(ismap(compilation.fileTimestamps)) {
60+
current = {};
61+
62+
compilation.fileTimestamps.forEach((value, key) => (current[key] = value));
63+
}
64+
65+
files = getChangedFiles(this.prev, current || compilation.fileTimestamps);
5766

5867
// Remove changed/removed files from processor instance
5968
this.processor.remove(files);

packages/webpack/test/__snapshots__/change.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/webpack/test/__snapshots__/default.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/webpack/test/__snapshots__/es2015-default.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/webpack/test/__snapshots__/es2015-named.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/webpack/test/__snapshots__/invalid-name.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/webpack/test/__snapshots__/invalid.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)