diff --git a/jest.config.js b/jest.config.js index 8a4be212e..cdd3722f3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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', { diff --git a/package.json b/package.json index e85041ff4..75d93397f 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ed5737d6..7b5477f69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,6 +27,9 @@ importers: '@release-it-plugins/lerna-changelog': specifier: ^6.1.0 version: 6.1.0(release-it@16.3.0) + '@rollup/plugin-typescript': + specifier: ^11.1.6 + version: 11.1.6(rollup@2.79.1)(typescript@5.3.3) '@testing-library/jest-dom': specifier: ^5.17.0 version: 5.17.0 @@ -195,6 +198,9 @@ importers: tailwindcss: specifier: ^3.4.1 version: 3.4.1 + typescript: + specifier: ^5.3.3 + version: 5.3.3 landing: dependencies: @@ -2598,6 +2604,25 @@ packages: - supports-color dev: true + /@rollup/plugin-typescript@11.1.6(rollup@2.79.1)(typescript@5.3.3): + resolution: {integrity: sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.14.0||^3.0.0||^4.0.0 + tslib: '*' + typescript: '>=3.7.0' + peerDependenciesMeta: + rollup: + optional: true + tslib: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@2.79.1) + resolve: 1.22.8 + rollup: 2.79.1 + typescript: 5.3.3 + dev: true + /@rollup/pluginutils@4.2.1: resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} engines: {node: '>= 8.0.0'} @@ -2606,6 +2631,21 @@ packages: picomatch: 2.3.1 dev: true + /@rollup/pluginutils@5.1.0(rollup@2.79.1): + resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@types/estree': 1.0.5 + estree-walker: 2.0.2 + picomatch: 2.3.1 + rollup: 2.79.1 + dev: true + /@rollup/rollup-android-arm-eabi@4.12.0: resolution: {integrity: sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w==} cpu: [arm] diff --git a/rollup.config.js b/rollup.config.js index b9b36d31a..aae536bb0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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(' '); @@ -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) @@ -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) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..fc383c097 --- /dev/null +++ b/tsconfig.json @@ -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"] +}