Skip to content

Commit

Permalink
👷‍ Add typescript with minimal setup
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckcarpenter authored and RobbieTheWagner committed Mar 2, 2024
1 parent 4896dbc commit b5907d7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
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
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"]
}

0 comments on commit b5907d7

Please sign in to comment.