Skip to content

Commit

Permalink
start to remove app utils (#600)
Browse files Browse the repository at this point in the history
* start to remove app utils

* bundle and transform filesystem module to cjs for builders

* remove all traces of app-utils

* prettier

* fix import in cli

* fix cjs output

* lint first!

* stop linting things prettier doesn't understand

* changeset

Co-authored-by: Antony Jones <antony@beyonk.com>
  • Loading branch information
antony and antony committed Mar 24, 2021
1 parent a1a6937 commit 8024178
Show file tree
Hide file tree
Showing 32 changed files with 295 additions and 313 deletions.
9 changes: 9 additions & 0 deletions .changeset/strange-hounds-invite.md
@@ -0,0 +1,9 @@
---
'@sveltejs/adapter-begin': patch
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-vercel': patch
'create-svelte': patch
'@sveltejs/kit': patch
---

remove @sveltejs/app-utils
42 changes: 22 additions & 20 deletions .github/workflows/ci.yml
Expand Up @@ -9,8 +9,28 @@ env:
CI: true

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache ~/.pnpm-store
uses: actions/cache@main
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}
- run: npm install -g pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build --filter ./packages
- run: pnpm lint
- run: pnpm check
Tests:
runs-on: ${{ matrix.os }}
needs: Lint
timeout-minutes: 6
strategy:
matrix:
Expand Down Expand Up @@ -41,6 +61,7 @@ jobs:
- run: pnpm test
Examples:
runs-on: ${{ matrix.os }}
needs: Tests
timeout-minutes: 6
strategy:
matrix:
Expand All @@ -67,23 +88,4 @@ jobs:
${{ runner.os }}-${{ matrix.node-version }}
- run: npm install -g pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm -r build
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache ~/.pnpm-store
uses: actions/cache@main
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}
- run: npm install -g pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build --filter ./packages
- run: pnpm lint
- run: pnpm check
- run: pnpm -r build
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -27,14 +27,14 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.6.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.21.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-svelte3": "^3.1.2",
"playwright": "^1.9.2",
"prettier": "2.2.1",
"rollup": "^2.41.1",
"rollup": "^2.42.3",
"typescript": "^4.2.3"
},
"type": "module"
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-begin/index.js
@@ -1,5 +1,4 @@
import { readFileSync, existsSync } from 'fs';
import { copy } from '@sveltejs/app-utils/files';
import { resolve, join } from 'path';
import parse from '@architect/parser';

Expand Down Expand Up @@ -40,7 +39,7 @@ export default function () {

builder.log.minor('Building lambda...');
const local_lambda_dir = join(__dirname, 'files');
copy(local_lambda_dir, lambda_directory);
builder.copy(local_lambda_dir, lambda_directory);

builder.log.minor('Writing server application...');
builder.copy_server_files(server_directory);
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-begin/package.json
Expand Up @@ -14,8 +14,7 @@
"files"
],
"dependencies": {
"@architect/parser": "^3.0.1",
"@sveltejs/app-utils": "workspace:*"
"@architect/parser": "^3.0.1"
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-node/package.json
Expand Up @@ -15,7 +15,6 @@
},
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
"@sveltejs/app-utils": "workspace:*",
"@sveltejs/kit": "workspace:*",
"compression": "^1.7.4",
"polka": "^0.5.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-node/src/server.js
Expand Up @@ -4,7 +4,8 @@ import polka from 'polka';
import { dirname, join } from 'path';
import sirv from 'sirv';
import { parse, URLSearchParams, fileURLToPath } from 'url';
import { get_body } from '@sveltejs/app-utils/http';
// eslint-disable-next-line import/no-unresolved
import { get_body } from '@sveltejs/kit/http';
// App is a dynamic file built from the application layer.
/*eslint import/no-unresolved: [2, { ignore: ['\.\/app\.js$'] }]*/
import * as app from './app.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-vercel/index.js
@@ -1,6 +1,5 @@
const { writeFileSync, mkdirSync, renameSync } = require('fs');
const { resolve, join } = require('path');
const { copy } = require('@sveltejs/app-utils/files');

module.exports = function () {
/** @type {import('@sveltejs/kit').Adapter} */
Expand All @@ -22,7 +21,7 @@ module.exports = function () {
builder.copy_server_files(server_directory);
renameSync(join(server_directory, 'app.js'), join(server_directory, 'app.mjs'));

copy(join(__dirname, 'files'), lambda_directory);
builder.copy(join(__dirname, 'files'), lambda_directory);

builder.log.minor('Prerendering static pages...');
await builder.prerender({
Expand Down
3 changes: 0 additions & 3 deletions packages/adapter-vercel/package.json
Expand Up @@ -13,9 +13,6 @@
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@sveltejs/app-utils": "workspace:*"
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"rollup": "^2.41.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-vercel/src/entry.js
@@ -1,5 +1,6 @@
import { URL, URLSearchParams } from 'url';
import { get_body } from '@sveltejs/app-utils/http';
// eslint-disable-next-line import/no-unresolved
import { get_body } from '@sveltejs/kit/http';

export default async (req, res) => {
const host = `${req.headers['x-forwarded-proto']}://${req.headers.host}`;
Expand Down
3 changes: 0 additions & 3 deletions packages/app-utils/.gitignore

This file was deleted.

96 changes: 0 additions & 96 deletions packages/app-utils/CHANGELOG.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/app-utils/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions packages/app-utils/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions packages/app-utils/tsconfig.json

This file was deleted.

3 changes: 2 additions & 1 deletion packages/create-svelte/cli/index.js
@@ -1,4 +1,5 @@
import { mkdirp } from '@sveltejs/app-utils/files';
//eslint-disable-next-line import/no-unresolved
import { mkdirp } from '@sveltejs/kit/filesystem';
import fs from 'fs';
import parser from 'gitignore-parser';
import { bold, cyan, gray, green, red } from 'kleur/colors';
Expand Down
1 change: 0 additions & 1 deletion packages/create-svelte/package.json
Expand Up @@ -5,7 +5,6 @@
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/app-utils": "workspace:*",
"@sveltejs/kit": "workspace:*",
"gitignore-parser": "^0.0.2",
"kleur": "^4.1.4",
Expand Down
8 changes: 7 additions & 1 deletion packages/kit/package.json
Expand Up @@ -9,7 +9,6 @@
},
"devDependencies": {
"@rollup/plugin-replace": "^2.4.1",
"@sveltejs/app-utils": "workspace:*",
"@types/amphtml-validator": "^1.0.1",
"@types/mime": "^2.0.3",
"@types/node": "^14.14.33",
Expand Down Expand Up @@ -62,6 +61,13 @@
"./ssr": {
"import": "./dist/ssr.js"
},
"./http": {
"import": "./dist/http.js"
},
"./filesystem": {
"import": "./dist/filesystem.js",
"require": "./dist/filesystem.cjs"
},
"./types.d.ts": "./types.d.ts"
},
"types": "types.d.ts"
Expand Down
28 changes: 27 additions & 1 deletion packages/kit/rollup.config.js
Expand Up @@ -40,7 +40,9 @@ export default [
{
input: {
cli: 'src/cli.js',
ssr: 'src/runtime/server/index.js'
ssr: 'src/runtime/server/index.js',
filesystem: 'src/core/filesystem/index.js',
http: 'src/core/http/index.js'
},
output: {
dir: 'dist',
Expand All @@ -63,5 +65,29 @@ export default [
commonjs()
],
preserveEntrySignatures: true
},

{
input: 'src/core/filesystem/index.js',
output: {
format: 'cjs',
file: 'dist/filesystem.cjs'
},
external: (id) => {
return external.includes(id);
},
plugins: [
replace({
preventAssignment: true,
values: {
__VERSION__: pkg.version
}
}),
resolve({
extensions: ['.mjs', '.js', '.ts']
}),
commonjs()
],
preserveEntrySignatures: true
}
];

0 comments on commit 8024178

Please sign in to comment.