mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-19 22:05:20 +00:00
Merge pull request #569 from sveltejs/update-rollup
update Rollup, remove some superfluous deps
This commit is contained in:
@@ -3,7 +3,6 @@ sudo: false
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- "6"
|
|
||||||
- "stable"
|
- "stable"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ build: off
|
|||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
# node.js
|
# node.js
|
||||||
- nodejs_version: 10.5
|
- nodejs_version: 11
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- ps: Install-Product node $env:nodejs_version
|
- ps: Install-Product node $env:nodejs_version
|
||||||
|
|||||||
2127
package-lock.json
generated
2127
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -20,17 +20,13 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"html-minifier": "^3.5.21",
|
"html-minifier": "^3.5.21",
|
||||||
"shimport": "0.0.14",
|
"shimport": "0.0.14",
|
||||||
"source-map-support": "^0.5.10",
|
|
||||||
"sourcemap-codec": "^1.4.4",
|
"sourcemap-codec": "^1.4.4",
|
||||||
"string-hash": "^1.1.3",
|
"string-hash": "^1.1.3"
|
||||||
"tslib": "^1.9.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/mkdirp": "^0.5.2",
|
|
||||||
"@types/mocha": "^5.2.5",
|
"@types/mocha": "^5.2.5",
|
||||||
"@types/node": "^10.12.21",
|
"@types/node": "^10.12.21",
|
||||||
"@types/puppeteer": "^1.11.3",
|
"@types/puppeteer": "^1.11.3",
|
||||||
"@types/rimraf": "^2.0.2",
|
|
||||||
"agadoo": "^1.0.1",
|
"agadoo": "^1.0.1",
|
||||||
"cheap-watch": "^1.0.2",
|
"cheap-watch": "^1.0.2",
|
||||||
"cookie": "^0.3.1",
|
"cookie": "^0.3.1",
|
||||||
@@ -38,7 +34,6 @@
|
|||||||
"eslint": "^5.12.1",
|
"eslint": "^5.12.1",
|
||||||
"eslint-plugin-import": "^2.16.0",
|
"eslint-plugin-import": "^2.16.0",
|
||||||
"kleur": "^3.0.1",
|
"kleur": "^3.0.1",
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.3.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
@@ -47,7 +42,6 @@
|
|||||||
"pretty-bytes": "^5.1.0",
|
"pretty-bytes": "^5.1.0",
|
||||||
"puppeteer": "^1.12.0",
|
"puppeteer": "^1.12.0",
|
||||||
"require-relative": "^0.8.7",
|
"require-relative": "^0.8.7",
|
||||||
"rimraf": "^2.6.3",
|
|
||||||
"rollup": "^1.1.2",
|
"rollup": "^1.1.2",
|
||||||
"rollup-plugin-commonjs": "^9.2.0",
|
"rollup-plugin-commonjs": "^9.2.0",
|
||||||
"rollup-plugin-json": "^3.1.0",
|
"rollup-plugin-json": "^3.1.0",
|
||||||
@@ -57,7 +51,6 @@
|
|||||||
"rollup-plugin-sucrase": "^2.1.0",
|
"rollup-plugin-sucrase": "^2.1.0",
|
||||||
"rollup-plugin-svelte": "^5.0.1",
|
"rollup-plugin-svelte": "^5.0.1",
|
||||||
"sade": "^1.4.2",
|
"sade": "^1.4.2",
|
||||||
"sander": "^0.6.0",
|
|
||||||
"sirv": "^0.2.2",
|
"sirv": "^0.2.2",
|
||||||
"sucrase": "^3.9.5",
|
"sucrase": "^3.9.5",
|
||||||
"svelte": "^3.0.0-alpha27",
|
"svelte": "^3.0.0-alpha27",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function template(kind, external) {
|
|||||||
|
|
||||||
export default [
|
export default [
|
||||||
template('app', id => /^(svelte\/?|@sapper\/)/.test(id)),
|
template('app', id => /^(svelte\/?|@sapper\/)/.test(id)),
|
||||||
template('server', id => builtinModules.includes(id)),
|
template('server', id => /^(svelte\/?|@sapper\/)/.test(id) || builtinModules.includes(id)),
|
||||||
|
|
||||||
{
|
{
|
||||||
input: [
|
input: [
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import mkdirp from 'mkdirp';
|
|
||||||
import rimraf from 'rimraf';
|
|
||||||
import minify_html from './utils/minify_html';
|
import minify_html from './utils/minify_html';
|
||||||
import { create_compilers, create_main_manifests, create_manifest_data, create_serviceworker_manifest } from '../core';
|
import { create_compilers, create_main_manifests, create_manifest_data, create_serviceworker_manifest } from '../core';
|
||||||
import { copy_shimport } from './utils/copy_shimport';
|
import { copy_shimport } from './utils/copy_shimport';
|
||||||
@@ -10,6 +8,7 @@ import { CompileResult } from '../core/create_compilers/interfaces';
|
|||||||
import { noop } from './utils/noop';
|
import { noop } from './utils/noop';
|
||||||
import validate_bundler from './utils/validate_bundler';
|
import validate_bundler from './utils/validate_bundler';
|
||||||
import { copy_runtime } from './utils/copy_runtime';
|
import { copy_runtime } from './utils/copy_runtime';
|
||||||
|
import { rimraf, mkdirp } from './utils/fs_utils';
|
||||||
|
|
||||||
type Opts = {
|
type Opts = {
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
@@ -48,12 +47,12 @@ export async function build({
|
|||||||
throw new Error(`Legacy builds are not supported for projects using webpack`);
|
throw new Error(`Legacy builds are not supported for projects using webpack`);
|
||||||
}
|
}
|
||||||
|
|
||||||
rimraf.sync(path.join(output, '**/*'));
|
rimraf(output);
|
||||||
mkdirp.sync(output);
|
mkdirp(output);
|
||||||
copy_runtime(output);
|
copy_runtime(output);
|
||||||
|
|
||||||
rimraf.sync(path.join(dest, '**/*'));
|
rimraf(dest);
|
||||||
mkdirp.sync(`${dest}/client`);
|
mkdirp(`${dest}/client`);
|
||||||
copy_shimport(dest);
|
copy_shimport(dest);
|
||||||
|
|
||||||
// minify src/template.html
|
// minify src/template.html
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import * as fs from 'fs';
|
|||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import * as ports from 'port-authority';
|
import * as ports from 'port-authority';
|
||||||
import mkdirp from 'mkdirp';
|
|
||||||
import rimraf from 'rimraf';
|
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { create_manifest_data, create_main_manifests, create_compilers, create_serviceworker_manifest } from '../core';
|
import { create_manifest_data, create_main_manifests, create_compilers, create_serviceworker_manifest } from '../core';
|
||||||
import { Compiler, Compilers } from '../core/create_compilers';
|
import { Compiler, Compilers } from '../core/create_compilers';
|
||||||
@@ -16,6 +14,7 @@ import { ManifestData, FatalEvent, ErrorEvent, ReadyEvent, InvalidEvent } from '
|
|||||||
import read_template from '../core/read_template';
|
import read_template from '../core/read_template';
|
||||||
import { noop } from './utils/noop';
|
import { noop } from './utils/noop';
|
||||||
import { copy_runtime } from './utils/copy_runtime';
|
import { copy_runtime } from './utils/copy_runtime';
|
||||||
|
import { rimraf, mkdirp } from './utils/fs_utils';
|
||||||
|
|
||||||
type Opts = {
|
type Opts = {
|
||||||
cwd?: string,
|
cwd?: string,
|
||||||
@@ -146,12 +145,12 @@ class Watcher extends EventEmitter {
|
|||||||
|
|
||||||
const { cwd, src, dest, routes, output, static: static_files } = this.dirs;
|
const { cwd, src, dest, routes, output, static: static_files } = this.dirs;
|
||||||
|
|
||||||
rimraf.sync(path.join(output, '**/*'));
|
rimraf(output);
|
||||||
mkdirp.sync(output);
|
mkdirp(output);
|
||||||
copy_runtime(output);
|
copy_runtime(output);
|
||||||
|
|
||||||
rimraf.sync(dest);
|
rimraf(dest);
|
||||||
mkdirp.sync(`${dest}/client`);
|
mkdirp(`${dest}/client`);
|
||||||
if (this.bundler === 'rollup') copy_shimport(dest);
|
if (this.bundler === 'rollup') copy_shimport(dest);
|
||||||
|
|
||||||
if (!this.dev_port) this.dev_port = await ports.find(10000);
|
if (!this.dev_port) this.dev_port = await ports.find(10000);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as sander from 'sander';
|
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import * as yootils from 'yootils';
|
import * as yootils from 'yootils';
|
||||||
@@ -9,6 +9,7 @@ import clean_html from './utils/clean_html';
|
|||||||
import minify_html from './utils/minify_html';
|
import minify_html from './utils/minify_html';
|
||||||
import Deferred from './utils/Deferred';
|
import Deferred from './utils/Deferred';
|
||||||
import { noop } from './utils/noop';
|
import { noop } from './utils/noop';
|
||||||
|
import { rimraf, copy, mkdirp } from './utils/fs_utils';
|
||||||
|
|
||||||
type Opts = {
|
type Opts = {
|
||||||
build_dir?: string,
|
build_dir?: string,
|
||||||
@@ -47,18 +48,12 @@ async function _export({
|
|||||||
export_dir = path.resolve(cwd, export_dir, basepath);
|
export_dir = path.resolve(cwd, export_dir, basepath);
|
||||||
|
|
||||||
// Prep output directory
|
// Prep output directory
|
||||||
sander.rimrafSync(export_dir);
|
rimraf(export_dir);
|
||||||
|
|
||||||
sander.copydirSync(static_files).to(export_dir);
|
copy(static_files, export_dir);
|
||||||
sander.copydirSync(build_dir, 'client').to(export_dir, 'client');
|
copy(path.join(build_dir, 'client'), path.join(export_dir, 'client'));
|
||||||
|
copy(path.join(build_dir, 'service-worker.js'), path.join(export_dir, 'service-worker.js'));
|
||||||
if (sander.existsSync(build_dir, 'service-worker.js')) {
|
copy(path.join(build_dir, 'service-worker.js.map'), path.join(export_dir, 'service-worker.js.map'));
|
||||||
sander.copyFileSync(build_dir, 'service-worker.js').to(export_dir, 'service-worker.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sander.existsSync(build_dir, 'service-worker.js.map')) {
|
|
||||||
sander.copyFileSync(build_dir, 'service-worker.js.map').to(export_dir, 'service-worker.js.map');
|
|
||||||
}
|
|
||||||
|
|
||||||
const port = await ports.find(3000);
|
const port = await ports.find(3000);
|
||||||
|
|
||||||
@@ -85,8 +80,8 @@ async function _export({
|
|||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const saved = new Set();
|
const saved = new Set();
|
||||||
|
|
||||||
function save(path: string, status: number, type: string, body: string) {
|
function save(url: string, status: number, type: string, body: string) {
|
||||||
const { pathname } = resolve(origin, path);
|
const { pathname } = resolve(origin, url);
|
||||||
let file = decodeURIComponent(pathname.slice(1));
|
let file = decodeURIComponent(pathname.slice(1));
|
||||||
|
|
||||||
if (saved.has(file)) return;
|
if (saved.has(file)) return;
|
||||||
@@ -107,7 +102,9 @@ async function _export({
|
|||||||
status
|
status
|
||||||
});
|
});
|
||||||
|
|
||||||
sander.writeFileSync(export_dir, file, body);
|
const export_file = path.join(export_dir, file);
|
||||||
|
mkdirp(path.dirname(export_file));
|
||||||
|
fs.writeFileSync(export_file, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc.on('message', message => {
|
proc.on('message', message => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import mkdirp from 'mkdirp';
|
import { mkdirp } from './fs_utils';
|
||||||
|
|
||||||
const runtime = [
|
const runtime = [
|
||||||
'app.mjs',
|
'app.mjs',
|
||||||
@@ -16,7 +16,7 @@ const runtime = [
|
|||||||
|
|
||||||
export function copy_runtime(output: string) {
|
export function copy_runtime(output: string) {
|
||||||
runtime.forEach(({ file, source }) => {
|
runtime.forEach(({ file, source }) => {
|
||||||
mkdirp.sync(path.dirname(`${output}/${file}`));
|
mkdirp(path.dirname(`${output}/${file}`));
|
||||||
fs.writeFileSync(`${output}/${file}`, source);
|
fs.writeFileSync(`${output}/${file}`, source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
46
src/api/utils/fs_utils.ts
Normal file
46
src/api/utils/fs_utils.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export function mkdirp(dir: string) {
|
||||||
|
const parent = path.dirname(dir);
|
||||||
|
if (parent === dir) return;
|
||||||
|
|
||||||
|
mkdirp(parent);
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rimraf(thing: string) {
|
||||||
|
if (!fs.existsSync(thing)) return;
|
||||||
|
|
||||||
|
const stats = fs.statSync(thing);
|
||||||
|
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
fs.readdirSync(thing).forEach(file => {
|
||||||
|
rimraf(path.join(thing, file));
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.rmdirSync(thing);
|
||||||
|
} else {
|
||||||
|
fs.unlinkSync(thing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function copy(from: string, to: string) {
|
||||||
|
if (!fs.existsSync(from)) return;
|
||||||
|
|
||||||
|
const stats = fs.statSync(from);
|
||||||
|
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
fs.readdirSync(from).forEach(file => {
|
||||||
|
copy(path.join(from, file), path.join(to, file));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mkdirp(path.dirname(to));
|
||||||
|
fs.writeFileSync(to, fs.readFileSync(from));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user