Skip to content

Commit 01eb1b5

Browse files
dominikgbluwy
andauthored
chore: cleanup after jsdoc (#659)
* refactor: move types to .d.ts files in preparation of ts-to-jsdoc * wip: convert ts to jsdoc * wip: ts to jsdoc * wip: ts to jsdoc conversion * wip: finished jsdoc conversion, renamed .d.ts files to avoid collisions, added .js ext to imports * test: add small wait for inspector icon to become visible to avoid flakiness in tests * wip: move internal types into src/types, improve index.d.ts * wip: move unit tests out of src dir and update filters * chore: switch to eslint-plugin-n to get rid of some errors * refactor: update jsdoc syntax (#656) * refactor: rename prepared .ts files to .js, update scripts, add changeset * fix: replace nullish assignment (requires node15) and enable error rules for invalid syntax that isn't downleveled anymore * chore: fix types path * remove tsup * chore(types): replace rollup types with vite reexport * chore: improve utility scripts, add publint * chore: call check:types and check:publint in public packages via filter * chore: disable tsc emit in inspector * chore: remove noop build script * chore: actually enable parallel processing for checks --------- Co-authored-by: Bjorn Lu <[email protected]>
1 parent 9685a62 commit 01eb1b5

File tree

23 files changed

+126
-238
lines changed

23 files changed

+126
-238
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
'n/no-extraneous-import': [
4444
'error',
4545
{
46-
allowModules: ['vite']
46+
allowModules: ['vite', 'vitest']
4747
}
4848
],
4949
'n/no-extraneous-require': [

.github/workflows/ci.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,22 @@ jobs:
5454
cache-dependency-path: '**/pnpm-lock.yaml'
5555
- name: install
5656
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
57-
- name: build
58-
id: build
59-
run: pnpm build
57+
- name: format
58+
run: pnpm check:format
6059
- name: lint
6160
if: (${{ success() }} || ${{ failure() }})
62-
run: pnpm lint
61+
run: pnpm check:lint
62+
- name: types
63+
if: (${{ success() }} || ${{ failure() }})
64+
run: pnpm check:types
6365
- name: audit
6466
if: (${{ success() }} || ${{ failure() }})
65-
run: pnpm audit
67+
run: pnpm check:audit
68+
- name: publint
69+
if: (${{ success() }} || ${{ failure() }})
70+
run: pnpm check:publint
6671

67-
# this is the test matrix, it runs with node16 on linux,windows,macos + node14,18 on linux
68-
# it is skipped if the build step of the checks job wasn't successful (still runs if lint or audit fail)
6972
test:
70-
needs: checks
71-
if: (${{ success() }} || ${{ failure() }}) && (${{ needs.checks.output.build_successful }})
7273
timeout-minutes: 10
7374
runs-on: ${{ matrix.os }}
7475
strategy:
@@ -111,8 +112,6 @@ jobs:
111112
- name: install for node14
112113
if: matrix.node == 14
113114
run: pnpm install --no-frozen-lockfile --prefer-offline --ignore-scripts
114-
- name: build
115-
run: pnpm build
116115
- name: install playwright chromium
117116
run: pnpm playwright install chromium
118117
- name: run tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ temp
77
**/temp
88
*.tmp
99
**/*.tmp
10+
.eslintcache
1011

1112
# build and dist
1213
build

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aggregate-output=true
2+
reporter=append-only

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
"name": "vite-plugin-svelte-monorepo",
33
"private": true,
44
"scripts": {
5-
"dev": "pnpm --dir packages/vite-plugin-svelte dev",
6-
"build": "pnpm --dir packages/vite-plugin-svelte build",
75
"test": "run-s -c test:unit test:build test:serve",
86
"test:unit": "vitest run",
97
"test:serve": "vitest run -c vitest.config.e2e.ts",
108
"test:build": "cross-env TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
11-
"lint": "eslint --ignore-path .gitignore '**/*.{js,ts,svelte,html,svx,md}'",
12-
"lint:fix": "pnpm lint --fix",
13-
"format": "prettier --ignore-path .gitignore '**/*.{css,scss,svelte,html,js,ts,svx,md}' --check",
14-
"format:fix": "pnpm format --write",
15-
"fixup": "run-s lint:fix format:fix",
16-
"release": "pnpm build && pnpm changeset publish",
9+
"check": "run-p -c check:*",
10+
"check:audit": "pnpm audit --prod",
11+
"check:publint": "pnpm --filter \"./packages/*\" --parallel check:publint",
12+
"check:types": "pnpm --filter \"./packages/*\" --parallel check:types",
13+
"check:lint": "eslint --cache --ignore-path .gitignore '**/*.{js,ts,svelte,html,svx,md}'",
14+
"check:format": "prettier --cache --ignore-path .gitignore '**/*.{css,scss,svelte,html,js,ts,svx,md}' --check",
15+
"lint": "pnpm check:lint --fix",
16+
"format": "pnpm check:format --write",
17+
"fixup": "run-s lint format",
18+
"release": "pnpm changeset publish",
1719
"prepare": "husky install"
1820
},
1921
"devDependencies": {
@@ -42,16 +44,17 @@
4244
"playwright-core": "^1.33.0",
4345
"prettier": "^2.8.8",
4446
"prettier-plugin-svelte": "^2.10.0",
47+
"publint": "^0.1.12",
4548
"rimraf": "^5.0.0",
4649
"svelte": "^3.59.1",
4750
"typescript": "^5.0.4",
4851
"vite": "^4.3.5",
4952
"vitest": "^0.31.0"
5053
},
5154
"lint-staged": {
52-
"*.{js,ts,svelte,html,md,svx}": "eslint --fix",
55+
"*.{js,ts,svelte,html,md,svx}": "eslint --cache --fix",
5356
"*.{css,scss,svelte,html,js,ts,svx,md}": [
54-
"prettier --write"
57+
"prettier --cache --write"
5558
]
5659
},
5760
"packageManager": "[email protected]",
@@ -61,8 +64,7 @@
6164
},
6265
"pnpm": {
6366
"overrides": {
64-
"@sveltejs/vite-plugin-svelte": "workspace:^",
65-
"tsup>postcss-load-config@<4": "^4.0.0"
67+
"@sveltejs/vite-plugin-svelte": "workspace:^"
6668
},
6769
"peerDependencyRules": {
6870
"allowedVersions": {

packages/e2e-tests/_test_dependencies/svelte-nested/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"name": "e2e-test-dep-svelte-nested",
55
"svelte": "src/index.js",
66
"main": "src/index.js",
7+
"type": "module",
78
"files": [
89
"src"
910
],

packages/e2e-tests/vite-ssr/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</head>
99
<body>
1010
<div id="svelte"><!--app-outlet--></div>
11-
<script type="module" src="/src/entry-client.js"></script>
11+
<script type="module" src="/src/entry-client.mjs"></script>
1212
</body>
1313
</html>

packages/e2e-tests/vite-ssr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "node server",
77
"build": "pnpm build:client && pnpm build:server",
88
"build:client": "vite build --ssrManifest --outDir dist/client",
9-
"build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
9+
"build:server": "vite build --ssr src/entry-server.mjs --outDir dist/server",
1010
"preview": "cross-env NODE_ENV=production node server",
1111
"debug": "node --inspect-brk server"
1212
},

packages/e2e-tests/vite-ssr/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function createServer(root = process.cwd(), isProd = process.env.NODE_ENV
6262
// always read fresh template in dev
6363
template = fs.readFileSync(resolve('index.html'), 'utf-8');
6464
template = await vite.transformIndexHtml(url, template);
65-
render = (await vite.ssrLoadModule('/src/entry-server.js')).render;
65+
render = (await vite.ssrLoadModule('/src/entry-server.mjs')).render;
6666
} else {
6767
template = indexProd;
6868
// @ts-ignore

packages/vite-plugin-svelte-inspector/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"import": "./src/index.js"
1515
}
1616
},
17+
"scripts": {
18+
"check:publint": "publint --strict",
19+
"check:types": "tsc --noEmit"
20+
},
1721
"engines": {
1822
"node": "^14.18.0 || >= 16"
1923
},

packages/vite-plugin-svelte-inspector/src/runtime/load-inspector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-expect-error missing
12
// eslint-disable-next-line n/no-missing-import
23
import Inspector from 'virtual:svelte-inspector-path:Inspector.svelte';
34

packages/vite-plugin-svelte-inspector/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["src"],
33
"exclude": ["**/*.spec.ts"],
44
"compilerOptions": {
5-
"outDir": "dist",
5+
"noEmit": true,
66
"target": "ES2020",
77
"module": "ES2020",
88
"moduleResolution": "node",
@@ -14,6 +14,8 @@
1414
"baseUrl": ".",
1515
"resolveJsonModule": true,
1616
// see https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-beta/#use-unknown-catch-variables
17-
"useUnknownInCatchVariables": false
17+
"useUnknownInCatchVariables": false,
18+
"allowJs": true,
19+
"checkJs": true
1820
}
1921
}

packages/vite-plugin-svelte/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
"./package.json": "./package.json"
1717
},
1818
"scripts": {
19-
"dev": "pnpm typecheck --watch",
20-
"build": "pnpm typecheck",
21-
"typecheck": "tsc --noEmit --allowJs --checkJs"
19+
"check:publint": "publint --strict",
20+
"check:types": "tsc --noEmit"
2221
},
2322
"engines": {
2423
"node": "^14.18.0 || >= 16"
@@ -54,9 +53,7 @@
5453
"devDependencies": {
5554
"@types/debug": "^4.1.7",
5655
"esbuild": "^0.17.18",
57-
"rollup": "^3.21.6",
5856
"svelte": "^3.59.1",
59-
"tsup": "^6.7.0",
6057
"vite": "^4.3.5"
6158
}
6259
}

packages/vite-plugin-svelte/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function svelte(inlineOptions) {
4848
let compileSvelte;
4949
/* eslint-enable no-unused-vars */
5050

51-
/** @type {Promise<import('rollup').PartialResolvedId | null>} */
51+
/** @type {Promise<import('vite').Rollup.PartialResolvedId | null>} */
5252
let resolvedSvelteSSR;
5353
/** @type {Set<string>} */
5454
let packagesWithResolveWarnings;

packages/vite-plugin-svelte/src/utils/error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { buildExtendedLogMessage } from './log.js';
44
* convert an error thrown by svelte.compile to a RollupError so that vite displays it in a user friendly way
55
* @param {import('svelte/types/compiler/interfaces').Warning & Error} error a svelte compiler error, which is a mix of Warning and an error
66
* @param {import('../types/options.d.ts').ResolvedOptions} options
7-
* @returns {import('rollup').RollupError} the converted error
7+
* @returns {import('vite').Rollup.RollupError} the converted error
88
*/
99
export function toRollupError(error, options) {
1010
const { filename, frame, start, code, name, stack } = error;
11-
/** @type {import('rollup').RollupError} */
11+
/** @type {import('vite').Rollup.RollupError} */
1212
const rollupError = {
1313
name, // needed otherwise sveltekit coalesce_to_error turns it into a string
1414
id: filename,

packages/vite-plugin-svelte/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["src"],
33
"exclude": ["**/*.spec.ts"],
44
"compilerOptions": {
5-
"outDir": "dist",
5+
"noEmit": true,
66
"target": "ES2020",
77
"module": "ES2020",
88
"moduleResolution": "node",

0 commit comments

Comments
 (0)