Skip to content

Commit

Permalink
fix: webpack tests (#414)
Browse files Browse the repository at this point in the history
#413 got things working, now the tests pass too!
  • Loading branch information
tivac committed Mar 8, 2018
1 parent 7b2f285 commit d240805
Show file tree
Hide file tree
Showing 25 changed files with 572 additions and 881 deletions.
8 changes: 4 additions & 4 deletions packages/svelte/test/__snapshots__/rollup.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function callAll(fns) {
}
function _mount(target, anchor) {
this._fragment.m(target, anchor);
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
function _unmount() {
Expand All @@ -194,7 +194,7 @@ var proto = {
function create_main_fragment(state, component) {
function create_main_fragment(component, state) {
var div, h1, text_1, div_1, p, p_class_value;
return {
Expand Down Expand Up @@ -238,11 +238,11 @@ function Svelte(options) {
init(this, options);
this._state = assign({}, options.data);
this._fragment = create_main_fragment(this._state, this);
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._fragment.m(options.target, options.anchor || null);
this._mount(options.target, options.anchor);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/webpack/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ var utils = require("loader-utils"),
module.exports = function(source) {
var options = utils.getOptions(this) || false,
done = this.async(),
processor = this.options
? this.options.processor // Webpack 2 & 3
: this._compiler.options.processor; // Webpack 4
processor = this.options ?
this.options.processor : // Webpack 2 & 3
this._compiler.options.processor; // Webpack 4

if(options.cjs) {
this.emitWarning(
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"esutils": "^2.0.2",
"loader-utils": "^1.1.0",
"lodash.ismap": "^4.4.2",
"modular-css-core": "^8.1.0",
"webpack-sources": "^1.0.1"
}
Expand Down
15 changes: 12 additions & 3 deletions packages/webpack/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";

var sources = require("webpack-sources"),
Processor = require("modular-css-core");
Processor = require("modular-css-core"),
ismap = require("lodash.ismap");

// Return a list of changed/removed files based on timestamp objects
function getChangedFiles(prev, curr) {
Expand Down Expand Up @@ -36,7 +37,7 @@ ModularCSS.prototype.apply = function(compiler) {
compiler.plugin("invalid", (file) => {
this.processor.remove(file);
});

compiler.plugin("watch-run", (c, done) => {
watching = true;

Expand All @@ -53,7 +54,15 @@ ModularCSS.prototype.apply = function(compiler) {
// This code is only useful when calling .run() multiple times
// watching handles its own invalidations
if(!watching) {
files = getChangedFiles(this.prev, compilation.fileTimestamps);
let current;

if(ismap(compilation.fileTimestamps)) {
current = {};

compilation.fileTimestamps.forEach((value, key) => (current[key] = value));
}

files = getChangedFiles(this.prev, current || compilation.fileTimestamps);

// Remove changed/removed files from processor instance
this.processor.remove(files);
Expand Down
21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/change.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/default.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/es2015-default.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/es2015-named.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/invalid-name.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/invalid.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/name.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/named.json

This file was deleted.

25 changes: 0 additions & 25 deletions packages/webpack/test/__snapshots__/simple.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/start.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/webpack/test/__snapshots__/watch.json

This file was deleted.

Loading

0 comments on commit d240805

Please sign in to comment.