From 6fd8fbf40b781ab9459344b27ddb11297e9aa8f8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 24 Nov 2018 18:54:50 -0500 Subject: [PATCH] dont try to be clever with module interop --- test/helpers.js | 12 ++++++------ test/hydration/index.js | 6 +++--- test/js/index.js | 2 +- test/parser/index.js | 4 ++-- test/preprocess/index.js | 2 +- test/runtime/index.js | 12 +++++++----- test/server-side-rendering/index.js | 4 ++-- test/setup.js | 5 +++-- test/sourcemaps/index.js | 2 +- test/stats/index.js | 2 +- test/validator/index.js | 2 +- 11 files changed, 28 insertions(+), 25 deletions(-) diff --git a/test/helpers.js b/test/helpers.js index 7a04ff0262..baa919c6e2 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1,9 +1,9 @@ -import jsdom from 'jsdom'; -import assert from 'assert'; -import glob from 'tiny-glob/sync.js'; -import fs from 'fs'; -import path from 'path'; -import chalk from 'chalk'; +import * as jsdom from 'jsdom'; +import * as assert from 'assert'; +import * as glob from 'tiny-glob/sync.js'; +import * as fs from 'fs'; +import * as path from 'path'; +import * as chalk from 'chalk'; // for coverage purposes, we need to test source files, // but for sanity purposes, we need to test dist files diff --git a/test/hydration/index.js b/test/hydration/index.js index 81634ea151..62d2632866 100644 --- a/test/hydration/index.js +++ b/test/hydration/index.js @@ -1,6 +1,6 @@ -import assert from 'assert'; -import path from 'path'; -import fs from 'fs'; +import * as assert from 'assert'; +import * as path from 'path'; +import * as fs from 'fs'; import { showOutput, diff --git a/test/js/index.js b/test/js/index.js index 9b9805f471..3ee1a1da2d 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -1,4 +1,4 @@ -import assert from "assert"; +import * as assert from "assert"; import * as fs from "fs"; import * as path from "path"; import { loadConfig, svelte } from "../helpers.js"; diff --git a/test/parser/index.js b/test/parser/index.js index 3cd7082ec0..1cf0bc29ab 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -1,5 +1,5 @@ -import assert from 'assert'; -import fs from 'fs'; +import * as assert from 'assert'; +import * as fs from 'fs'; import { svelte, tryToLoadJson } from '../helpers.js'; describe('parse', () => { diff --git a/test/preprocess/index.js b/test/preprocess/index.js index 044f6965e6..51f1d168ce 100644 --- a/test/preprocess/index.js +++ b/test/preprocess/index.js @@ -1,4 +1,4 @@ -import assert from 'assert'; +import * as assert from 'assert'; import { svelte } from '../helpers.js'; describe('preprocess', () => { diff --git a/test/runtime/index.js b/test/runtime/index.js index de1bc31c0f..ea335e9bd2 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -1,8 +1,8 @@ -import assert from "assert"; +import * as assert from "assert"; import * as path from "path"; import * as fs from "fs"; import { rollup } from 'rollup'; -import virtual from 'rollup-plugin-virtual'; +import * as virtual from 'rollup-plugin-virtual'; import { transitionManager } from "../../internal.js"; import { @@ -119,7 +119,7 @@ describe.only("runtime", () => { mod = require(`./samples/${dir}/main.html`); SvelteComponent = mod.default; } catch (err) { - showOutput(cwd, { internal, hydratable: hydrate }, svelte.compile); // eslint-disable-line no-console + showOutput(cwd, { internal, hydratable: hydrate, format: 'cjs' }, svelte.compile); // eslint-disable-line no-console throw err; } @@ -191,7 +191,8 @@ describe.only("runtime", () => { showOutput(cwd, { internal, hydratable: hydrate, - dev: compileOptions.dev + dev: compileOptions.dev, + format: 'cjs' }, svelte.compile); // eslint-disable-line no-console throw err; } @@ -200,7 +201,8 @@ describe.only("runtime", () => { if (config.show) { showOutput(cwd, { internal, - hydratable: hydrate + hydratable: hydrate, + format: 'cjs' }, svelte.compile); } diff --git a/test/server-side-rendering/index.js b/test/server-side-rendering/index.js index 5a0a0d6b12..b0dfc119a0 100644 --- a/test/server-side-rendering/index.js +++ b/test/server-side-rendering/index.js @@ -1,7 +1,7 @@ -import assert from "assert"; +import * as assert from "assert"; import * as fs from "fs"; import * as path from "path"; -import glob from 'tiny-glob/sync.js'; +import * as glob from 'tiny-glob/sync.js'; import { showOutput, diff --git a/test/setup.js b/test/setup.js index 806e394f22..8bb73d81d0 100644 --- a/test/setup.js +++ b/test/setup.js @@ -8,9 +8,10 @@ require.extensions['.js'] = function(module, filename) { const exports = []; var code = fs.readFileSync(filename, 'utf-8') - .replace(/^import (?:\* as )?(\w+) from ['"]([^'"]+)['"];?/gm, 'var $1 = require("$2");') + .replace(/^import \* as (\w+) from ['"]([^'"]+)['"];?/gm, 'var $1 = require("$2");') + .replace(/^import (\w+) from ['"]([^'"]+)['"];?/gm, 'var {default: $1} = require("$2");') .replace(/^import {([^}]+)} from ['"](.+)['"];?/gm, 'var {$1} = require("$2");') - .replace(/^export default /gm, 'module.exports = ') + .replace(/^export default /gm, 'exports.default = ') .replace(/^export (const|let|var|class|function) (\w+)/gm, (match, type, name) => { exports.push(name); return `${type} ${name}`; diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js index eade146f39..33df9b5505 100644 --- a/test/sourcemaps/index.js +++ b/test/sourcemaps/index.js @@ -1,6 +1,6 @@ import * as fs from "fs"; import * as path from "path"; -import assert from "assert"; +import * as assert from "assert"; import { loadConfig, svelte } from "../helpers.js"; import { SourceMapConsumer } from "source-map"; import { getLocator } from "locate-character"; diff --git a/test/stats/index.js b/test/stats/index.js index 550c887a6a..b3b3fdc14c 100644 --- a/test/stats/index.js +++ b/test/stats/index.js @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import assert from 'assert'; +import * as assert from 'assert'; import { svelte, loadConfig, tryToLoadJson } from '../helpers.js'; describe('stats', () => { diff --git a/test/validator/index.js b/test/validator/index.js index 0f5ad18a6e..6a1b446617 100644 --- a/test/validator/index.js +++ b/test/validator/index.js @@ -1,5 +1,5 @@ import * as fs from "fs"; -import assert from "assert"; +import * as assert from "assert"; import { svelte, loadConfig, tryToLoadJson } from "../helpers.js"; describe("validate", () => {