Skip to content

Commit 99beb6b

Browse files
committed
update things add svelte support
1 parent 76e8f7b commit 99beb6b

File tree

12 files changed

+89
-19
lines changed

12 files changed

+89
-19
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const config = {
3232
'@typescript-eslint/no-empty-function': 'off',
3333
'@typescript-eslint/no-inferrable-types': 'off',
3434
'@typescript-eslint/explicit-function-return-type': ['warn'],
35+
'@typescript-eslint/require-await': 'off',
3536
},
3637
};
3738

.prettierrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2+
"plugins": ["prettier-plugin-svelte"],
3+
24
"printWidth": 160,
35
"useTabs": true,
46
"semi": true,
57
"singleQuote": true,
6-
"arrowParens": "avoid"
8+
"arrowParens": "avoid",
9+
10+
"svelteAllowShorthand": false
711
}

automation/release.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ async function run() {
7070
const manifestFile = Bun.file('./manifest.json');
7171
const manifest = await manifestFile.json();
7272

73-
const betaManifestFile = Bun.file('./manifest-beta.json');
74-
const betaManifest = await betaManifestFile.json();
75-
7673
const versionString: string = manifest.version;
7774
const currentVersion: Version = parseVersion(versionString);
7875
const currentVersionString = stringifyVersion(currentVersion);
@@ -96,9 +93,12 @@ async function run() {
9693
manifest.version = newVersionString;
9794
}
9895

96+
await Bun.write(manifestFile, JSON.stringify(manifest, null, '\t'));
97+
98+
const betaManifest = structuredClone(manifest);
9999
betaManifest.version = newVersionString;
100100

101-
await Bun.write(manifestFile, JSON.stringify(manifest, null, '\t'));
101+
const betaManifestFile = Bun.file('./manifest-beta.json');
102102
await Bun.write(betaManifestFile, JSON.stringify(betaManifest, null, '\t'));
103103

104104
if (!(newVersion instanceof CanaryVersion)) {

bun.lockb

-80 KB
Binary file not shown.

bunfig.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[test]
2+
preload = ["./tests/svelteLoader.ts", "./tests/happydom.ts", "./tests/obsidianMock.ts"]
3+
root = "./tests"

esbuild.config.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import esbuild from 'esbuild';
22
import process from 'process';
33
import builtins from 'builtin-modules';
4+
import esbuildSvelte from 'esbuild-svelte';
5+
import sveltePreprocess from 'svelte-preprocess';
46
import manifest from './manifest.json' assert { type: 'json' };
57

68
const banner = `/*
@@ -46,6 +48,15 @@ esbuild
4648
treeShaking: true,
4749
outfile: 'main.js',
4850
minify: true,
49-
plugins: [],
51+
plugins: [
52+
esbuildSvelte({
53+
compilerOptions: { css: 'injected' },
54+
preprocess: sveltePreprocess(),
55+
filterWarnings: warning => {
56+
// we don't want warnings from node modules that we can do nothing about
57+
return !warning.filename.includes('node_modules');
58+
},
59+
}),
60+
],
5061
})
5162
.catch(() => process.exit(1));

esbuild.dev.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import esbuild from 'esbuild';
22
import process from 'process';
33
import builtins from 'builtin-modules';
44
import copy from 'esbuild-plugin-copy-watch';
5+
import esbuildSvelte from 'esbuild-svelte';
6+
import sveltePreprocess from 'svelte-preprocess';
57
import manifest from './manifest.json' assert { type: 'json' };
68

79
const banner = `/*
@@ -61,6 +63,14 @@ esbuild
6163
},
6264
],
6365
}),
66+
esbuildSvelte({
67+
compilerOptions: { css: 'injected' },
68+
preprocess: sveltePreprocess(),
69+
filterWarnings: warning => {
70+
// we don't want warnings from node modules that we can do nothing about
71+
return !warning.filename.includes('node_modules');
72+
},
73+
}),
6474
],
6575
})
6676
.catch(() => process.exit(1));

package.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,43 @@
66
"scripts": {
77
"dev": "bun esbuild.dev.config.mjs",
88
"build": "tsc -noEmit -skipLibCheck && bun esbuild.config.mjs production",
9+
"tsc": "tsc -noEmit -skipLibCheck",
910
"test": "bun test",
10-
"format": "prettier --write .",
11+
"test:log": "LOG_TESTS=true bun test",
12+
"format": "prettier --write --plugin prettier-plugin-svelte .",
13+
"format:check": "prettier --check --plugin prettier-plugin-svelte .",
1114
"lint": "eslint --max-warnings=0 src/**",
1215
"lint:fix": "eslint --max-warnings=0 --fix src/**",
16+
"check": "bun run format:check && bun run lint && bun run tsc && bun run test",
17+
"check:fix": "bun run format && bun run lint:fix && bun run tsc && bun run test",
1318
"release": "bun run automation/release.ts"
1419
},
1520
"keywords": [],
1621
"author": "Moritz Jung",
1722
"license": "GPL-3.0",
1823
"devDependencies": {
19-
"@lemons_dev/parsinom": "^0.0.10",
20-
"@types/node": "^20.3.2",
21-
"@types/ungap__structured-clone": "^0.3.0",
24+
"@lemons_dev/parsinom": "^0.0.12",
25+
"@happy-dom/global-registrator": "^12.10.3",
26+
"@tsconfig/svelte": "^5.0.0",
27+
"@types/web": "^0.0.119",
2228
"@typescript-eslint/eslint-plugin": "^6.0.0",
2329
"@typescript-eslint/parser": "^6.0.0",
2430
"builtin-modules": "^3.3.0",
25-
"bun-types": "^1.0.7",
26-
"esbuild": "^0.17.0",
31+
"bun-types": "1.0.11",
32+
"esbuild": "^0.19.5",
2733
"esbuild-plugin-copy-watch": "^2.0.0",
28-
"esbuild-svelte": "^0.7.1",
34+
"esbuild-svelte": "^0.8.0",
2935
"eslint": "^8.52.0",
3036
"eslint-plugin-import": "^2.28.1",
3137
"eslint-plugin-isaacscript": "^3.5.6",
3238
"eslint-plugin-only-warn": "^1.1.0",
3339
"obsidian": "latest",
34-
"prettier": "3.0.3",
40+
"prettier": "^3.0.3",
41+
"prettier-plugin-svelte": "^3.0.3",
3542
"string-argv": "^0.3.2",
36-
"ts-jest": "^29.1.1",
37-
"tslib": "2.4.0",
43+
"svelte": "^4.2.0",
44+
"svelte-preprocess": "^5.0.4",
45+
"tslib": "2.6.2",
3846
"typescript": "^5.2.2"
3947
}
4048
}

tests/happydom.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { GlobalRegistrator } from '@happy-dom/global-registrator';
2+
import process from 'process';
3+
4+
const oldConsole = console;
5+
GlobalRegistrator.register();
6+
if (process.env.LOG_TESTS) {
7+
window.console = oldConsole;
8+
}

tests/obsidianMock.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { mock } from 'bun:test';
2+
import Moment from 'moment';
3+
4+
mock.module('obsidian', () => ({
5+
setIcon(iconEl: HTMLElement, iconName: string): void {
6+
// do nothing
7+
},
8+
moment: Moment,
9+
}));

0 commit comments

Comments
 (0)