mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
write ssr compiled output to disk for easier inspection
This commit is contained in:
parent
75b8d3fb21
commit
140bfd0ce2
@ -1,13 +1,16 @@
|
|||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
import * as glob from 'tiny-glob/sync.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
showOutput,
|
showOutput,
|
||||||
loadConfig,
|
loadConfig,
|
||||||
|
loadSvelte,
|
||||||
setupHtmlEqual,
|
setupHtmlEqual,
|
||||||
tryToLoadJson,
|
tryToLoadJson,
|
||||||
shouldUpdateExpected
|
shouldUpdateExpected,
|
||||||
|
mkdirp
|
||||||
} from "../helpers.js";
|
} from "../helpers.js";
|
||||||
|
|
||||||
function tryToReadFile(file) {
|
function tryToReadFile(file) {
|
||||||
@ -20,6 +23,7 @@ function tryToReadFile(file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sveltePath = process.cwd().split('\\').join('/');
|
const sveltePath = process.cwd().split('\\').join('/');
|
||||||
|
let compile = null;
|
||||||
|
|
||||||
describe("ssr", () => {
|
describe("ssr", () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
@ -28,6 +32,8 @@ describe("ssr", () => {
|
|||||||
sveltePath
|
sveltePath
|
||||||
});
|
});
|
||||||
|
|
||||||
|
compile = loadSvelte(true).compile;
|
||||||
|
|
||||||
return setupHtmlEqual();
|
return setupHtmlEqual();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -142,6 +148,33 @@ describe("ssr", () => {
|
|||||||
|
|
||||||
require("../../register")(compileOptions);
|
require("../../register")(compileOptions);
|
||||||
|
|
||||||
|
glob('**/*.svelte', { cwd }).forEach(file => {
|
||||||
|
if (file[0] === '_') return;
|
||||||
|
|
||||||
|
const dir = `${cwd}/_output/ssr`;
|
||||||
|
const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`;
|
||||||
|
|
||||||
|
if (fs.existsSync(out)) {
|
||||||
|
fs.unlinkSync(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdirp(dir);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { js } = compile(
|
||||||
|
fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
|
||||||
|
{
|
||||||
|
...compileOptions,
|
||||||
|
filename: file
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
fs.writeFileSync(out, js.code);
|
||||||
|
} catch (err) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (config.before_test) config.before_test();
|
if (config.before_test) config.before_test();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user