dont try to be clever with module interop

pull/1864/head
Rich Harris 7 years ago
parent 210173e429
commit 6fd8fbf40b

@ -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

@ -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,

@ -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";

@ -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', () => {

@ -1,4 +1,4 @@
import assert from 'assert';
import * as assert from 'assert';
import { svelte } from '../helpers.js';
describe('preprocess', () => {

@ -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);
}

@ -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,

@ -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}`;

@ -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";

@ -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', () => {

@ -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", () => {

Loading…
Cancel
Save