Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
default to generating app in src/node_modules/@sapper - fixes #551
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 31, 2019
1 parent 76ce7f2 commit 90f3393
Show file tree
Hide file tree
Showing 41 changed files with 87 additions and 85 deletions.
5 changes: 4 additions & 1 deletion src/api/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function build({
cwd,
src = 'src',
routes = 'src/routes',
output = '__sapper__',
output = 'src/node_modules/@sapper',
static: static_files = 'static',
dest = '__sapper__/build',

Expand All @@ -48,6 +48,9 @@ export async function build({
throw new Error(`Legacy builds are not supported for projects using webpack`);
}

rimraf.sync(path.join(output, '**/*'));
mkdirp.sync(output);

rimraf.sync(path.join(dest, '**/*'));
mkdirp.sync(`${dest}/client`);
copy_shimport(dest);
Expand Down
6 changes: 3 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ prog.command('dev')
.option('--src', 'Source directory', 'src')
.option('--routes', 'Routes directory', 'src/routes')
.option('--static', 'Static files directory', 'static')
.option('--output', 'Sapper output directory', '__sapper__')
.option('--output', 'Sapper output directory', 'src/node_modules/@sapper')
.option('--build-dir', 'Development build directory', '__sapper__/dev')
.action(async (opts: {
port: number,
Expand Down Expand Up @@ -142,7 +142,7 @@ prog.command('build [dest]')
.option('--cwd', 'Current working directory', '.')
.option('--src', 'Source directory', 'src')
.option('--routes', 'Routes directory', 'src/routes')
.option('--output', 'Sapper output directory', '__sapper__')
.option('--output', 'Sapper output directory', 'src/node_modules/@sapper')
.example(`build custom-dir -p 4567`)
.action(async (dest = '__sapper__/build', opts: {
port: string,
Expand Down Expand Up @@ -188,7 +188,7 @@ prog.command('export [dest]')
.option('--src', 'Source directory', 'src')
.option('--routes', 'Routes directory', 'src/routes')
.option('--static', 'Static files directory', 'static')
.option('--output', 'Sapper output directory', '__sapper__')
.option('--output', 'Sapper output directory', 'src/node_modules/@sapper')
.option('--build-dir', 'Intermediate build directory', '__sapper__/build')
.action(async (dest = '__sapper__/export', opts: {
build: boolean,
Expand Down
2 changes: 1 addition & 1 deletion test/apps/basics/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/basics/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
13 changes: 6 additions & 7 deletions test/apps/basics/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
// `app.shell` is an array of all the files generated by webpack,
// `app.files` is an array of everything in the `static` directory
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -52,7 +52,6 @@ self.addEventListener('fetch', event => {
// which Sapper has generated for you. It's not right for every
// app, but if it's right for yours then uncomment this section
/*
if (url.origin === self.origin && routes.find(route => route.pattern.test(url.pathname))) {
event.respondWith(caches.match('/index.html'));
return;
}
Expand All @@ -65,7 +64,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/credentials/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/credentials/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/credentials/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/css/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/css/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/css/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/encoding/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/encoding/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/encoding/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/errors/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/errors/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/errors/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/export/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/export/src/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sirv from 'sirv';
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
Expand Down
8 changes: 4 additions & 4 deletions test/apps/export/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/ignore/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/ignore/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/ignore/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/layout/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/layout/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/layout/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/preloading/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/preloading/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down
8 changes: 4 additions & 4 deletions test/apps/preloading/src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
import * as sapper from '@sapper/service-worker';

const ASSETS = `cache${timestamp}`;
const ASSETS = `cache${sapper.timestamp}`;

// `shell` is an array of all the files generated by webpack,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(ASSETS);
const to_cache = sapper.shell.concat(sapper.files);
const cached = new Set(to_cache);

self.addEventListener('install', event => {
Expand Down Expand Up @@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.open(`offline${sapper.timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
Expand Down
2 changes: 1 addition & 1 deletion test/apps/redirects/src/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sapper from '../__sapper__/client.js';
import * as sapper from '@sapper/client';

window.start = () => sapper.start({
target: document.querySelector('#sapper')
Expand Down
2 changes: 1 addition & 1 deletion test/apps/redirects/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polka from 'polka';
import * as sapper from '../__sapper__/server.js';
import * as sapper from '@sapper/server';

const { PORT } = process.env;

Expand Down

0 comments on commit 90f3393

Please sign in to comment.