Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷‍ Add typescript with minimal setup #2601

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {

// A map from regular expressions to paths to transformers
transform: {
'^.+\\.js$': 'babel-jest',
'\\.[jt]s?$': 'babel-jest',
'^.+\\.svelte$': [
'svelte-jester',
{
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@release-it-plugins/lerna-changelog": "^6.1.0",
"@rollup/plugin-typescript": "^11.1.6",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/svelte": "^3.2.2",
"autoprefixer": "^10.4.16",
Expand Down Expand Up @@ -113,7 +114,8 @@
"svelte": "^3.59.2",
"svelte-jester": "^2.3.2",
"svelte-preprocess": "^5.1.3",
"tailwindcss": "^3.4.1"
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
},
"engines": {
"node": "18.* || >= 20"
Expand Down
40 changes: 40 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import resolve from 'rollup-plugin-node-resolve';
import sveltePreprocess from 'svelte-preprocess';
import svelte from 'rollup-plugin-svelte';
import visualizer from 'rollup-plugin-visualizer';
import typescript from '@rollup/plugin-typescript';

const pkg = require('./package.json');
const banner = ['/*!', pkg.name, pkg.version, '*/\n'].join(' ');
Expand All @@ -20,12 +21,13 @@ const env = process.env.DEVELOPMENT ? 'development' : 'production';

const plugins = [
svelte({
preprocess: sveltePreprocess(),
preprocess: sveltePreprocess({ typescript: true }),
emitCss: true
}),
resolve({
extensions: ['.js', '.json', '.svelte']
extensions: ['.js', '.json', '.svelte', '.ts']
}),
typescript(),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
Expand Down Expand Up @@ -95,12 +97,13 @@ if (!process.env.DEVELOPMENT) {
],
plugins: [
svelte({
preprocess: sveltePreprocess(),
preprocess: sveltePreprocess({ typescript: true }),
emitCss: true
}),
resolve({
extensions: ['.js', '.json', '.svelte']
extensions: ['.js', '.json', '.svelte', '.ts']
}),
typescript(),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"typeRoots": ["./src/types"],
"types": ["shepherd.js"],
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"allowJs": true
},
"include": ["src"],
"exclude": ["node_modules"]
}
Loading