From 4f1b28995507732f069f542b779c799dfac9cd09 Mon Sep 17 00:00:00 2001 From: Luca Pipolo Date: Tue, 9 Apr 2024 14:48:50 +0200 Subject: [PATCH] feat: add support for typescript --- README.md | 7 --- package.json | 4 +- pnpm-lock.yaml | 163 ++++++++++++++++++++++++++++--------------------- tsconfig.json | 9 +++ webpack.mix.js | 23 ++++--- 5 files changed, 123 insertions(+), 83 deletions(-) create mode 100644 tsconfig.json diff --git a/README.md b/README.md index 977f297..e67f5b8 100644 --- a/README.md +++ b/README.md @@ -601,13 +601,6 @@ Additionally, we use [PHPStan](https://phpstan.org/) for static analysis, which significantly improves our code quality by detecting bugs and potential issues before runtime. -## Future Functionality - -In our roadmap for the theme's evolution, we plan to introduce the following -features: - -- TypeScript Adoption - ## How to Contribute Any kind of contribution is very welcome! diff --git a/package.json b/package.json index 0056d1c..2112c2f 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,8 @@ "storybook": "^8.0.5", "stylelint": "^16.3.0", "stylelint-config-recommended": "^14.0.0", - "twigjs-loader": "^1.0.3" + "ts-loader": "^9.5.1", + "twigjs-loader": "^1.0.3", + "typescript": "^5.4.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53b3472..9a9d278 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,7 +33,7 @@ dependencies: devDependencies: '@commitlint/cli': specifier: ^19.2.1 - version: 19.2.1(@types/node@20.11.30)(typescript@5.4.3) + version: 19.2.1(@types/node@20.11.30)(typescript@5.4.4) '@commitlint/config-conventional': specifier: ^19.1.0 version: 19.1.0 @@ -51,13 +51,13 @@ devDependencies: version: 8.0.5(@types/react@18.2.73)(react-dom@18.2.0)(react@18.2.0) '@storybook/html-webpack5': specifier: ^8.0.5 - version: 8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.3)(webpack-cli@4.10.0) + version: 8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.4)(webpack-cli@4.10.0) '@storybook/theming': specifier: ^8.0.5 version: 8.0.5(react-dom@18.2.0)(react@18.2.0) '@wordpress/eslint-plugin': specifier: ^17.11.0 - version: 17.11.0(@babel/core@7.24.3)(eslint@8.57.0)(prettier@3.2.5)(typescript@5.4.3) + version: 17.11.0(@babel/core@7.24.3)(eslint@8.57.0)(prettier@3.2.5)(typescript@5.4.4) '@wordpress/prettier-config': specifier: ^3.11.0 version: 3.11.0(prettier@3.2.5) @@ -78,7 +78,7 @@ devDependencies: version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) eslint-plugin-storybook: specifier: ^0.8.0 - version: 0.8.0(eslint@8.57.0)(typescript@5.4.3) + version: 0.8.0(eslint@8.57.0)(typescript@5.4.4) husky: specifier: ^9.0.11 version: 9.0.11 @@ -96,13 +96,19 @@ devDependencies: version: 8.0.5(@babel/preset-env@7.24.3)(react-dom@18.2.0)(react@18.2.0) stylelint: specifier: ^16.3.0 - version: 16.3.0(typescript@5.4.3) + version: 16.3.0(typescript@5.4.4) stylelint-config-recommended: specifier: ^14.0.0 version: 14.0.0(stylelint@16.3.0) + ts-loader: + specifier: ^9.5.1 + version: 9.5.1(typescript@5.4.4)(webpack@5.91.0) twigjs-loader: specifier: ^1.0.3 version: 1.0.3(twig@1.17.1) + typescript: + specifier: ^5.4.4 + version: 5.4.4 packages: @@ -1347,14 +1353,14 @@ packages: requiresBuild: true optional: true - /@commitlint/cli@19.2.1(@types/node@20.11.30)(typescript@5.4.3): + /@commitlint/cli@19.2.1(@types/node@20.11.30)(typescript@5.4.4): resolution: {integrity: sha512-cbkYUJsLqRomccNxvoJTyv5yn0bSy05BBizVyIcLACkRbVUqYorC351Diw/XFSWC/GtpwiwT2eOvQgFZa374bg==} engines: {node: '>=v18'} hasBin: true dependencies: '@commitlint/format': 19.0.3 '@commitlint/lint': 19.1.0 - '@commitlint/load': 19.2.0(@types/node@20.11.30)(typescript@5.4.3) + '@commitlint/load': 19.2.0(@types/node@20.11.30)(typescript@5.4.4) '@commitlint/read': 19.2.1 '@commitlint/types': 19.0.3 execa: 8.0.1 @@ -1423,7 +1429,7 @@ packages: '@commitlint/types': 19.0.3 dev: true - /@commitlint/load@19.2.0(@types/node@20.11.30)(typescript@5.4.3): + /@commitlint/load@19.2.0(@types/node@20.11.30)(typescript@5.4.4): resolution: {integrity: sha512-XvxxLJTKqZojCxaBQ7u92qQLFMMZc4+p9qrIq/9kJDy8DOrEa7P1yx7Tjdc2u2JxIalqT4KOGraVgCE7eCYJyQ==} engines: {node: '>=v18'} dependencies: @@ -1432,8 +1438,8 @@ packages: '@commitlint/resolve-extends': 19.1.0 '@commitlint/types': 19.0.3 chalk: 5.3.0 - cosmiconfig: 9.0.0(typescript@5.4.3) - cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.30)(cosmiconfig@9.0.0)(typescript@5.4.3) + cosmiconfig: 9.0.0(typescript@5.4.4) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.30)(cosmiconfig@9.0.0)(typescript@5.4.4) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -2148,7 +2154,7 @@ packages: - supports-color dev: true - /@storybook/builder-webpack5@8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.3)(webpack-cli@4.10.0): + /@storybook/builder-webpack5@8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.4)(webpack-cli@4.10.0): resolution: {integrity: sha512-tt7ZrRscsg+AJayOLXYCsDleNzNy0UHjfs7FnDzh331Ulyt2WeGkcELTZmHnBg5WwVBgjGTYmxYKSgGXF0hKXQ==} peerDependencies: typescript: '*' @@ -2173,7 +2179,7 @@ packages: css-loader: 6.10.0(webpack@5.91.0) es-module-lexer: 1.4.2 express: 4.19.1 - fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.4.3)(webpack@5.91.0) + fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.4.4)(webpack@5.91.0) fs-extra: 11.2.0 html-webpack-plugin: 5.6.0(webpack@5.91.0) magic-string: 0.30.8 @@ -2183,7 +2189,7 @@ packages: style-loader: 3.3.4(webpack@5.91.0) terser-webpack-plugin: 5.3.10(@swc/core@1.4.11)(esbuild@0.20.2)(webpack@5.91.0) ts-dedent: 2.2.0 - typescript: 5.4.3 + typescript: 5.4.4 url: 0.11.3 util: 0.12.5 util-deprecate: 1.0.2 @@ -2480,11 +2486,11 @@ packages: resolution: {integrity: sha512-FcOqPAXACP0I3oJ/ws6/rrPT9WGhu915Cg8D02a9YxLo0DE9zI+a9A5gRGvmQ09fiWPukqI8ZAEoQEdWUKMQdQ==} dev: true - /@storybook/html-webpack5@8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.3)(webpack-cli@4.10.0): + /@storybook/html-webpack5@8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.4)(webpack-cli@4.10.0): resolution: {integrity: sha512-bzjvteMGxWh/VC106eP0wjLyxBCkgK2jDh8bcZPtI7ybuhrZaboJefzo7xMvV2dnMxbwdX47WqI3+0Toh54biQ==} engines: {node: '>=18.0.0'} dependencies: - '@storybook/builder-webpack5': 8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.3)(webpack-cli@4.10.0) + '@storybook/builder-webpack5': 8.0.5(@swc/core@1.4.11)(esbuild@0.20.2)(typescript@5.4.4)(webpack-cli@4.10.0) '@storybook/core-common': 8.0.5 '@storybook/global': 5.0.0 '@storybook/html': 8.0.5 @@ -3072,7 +3078,7 @@ packages: '@types/node': 20.11.30 dev: false - /@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.3): + /@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -3084,10 +3090,10 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.4) '@typescript-eslint/scope-manager': 6.21.0 - '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.0)(typescript@5.4.3) - '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.4) '@typescript-eslint/visitor-keys': 6.21.0 debug: 4.3.4 eslint: 8.57.0 @@ -3095,13 +3101,13 @@ packages: ignore: 5.3.1 natural-compare: 1.4.0 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.4.3) - typescript: 5.4.3 + ts-api-utils: 1.3.0(typescript@5.4.4) + typescript: 5.4.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.4.3): + /@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -3113,11 +3119,11 @@ packages: dependencies: '@typescript-eslint/scope-manager': 6.21.0 '@typescript-eslint/types': 6.21.0 - '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.3) + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.4) '@typescript-eslint/visitor-keys': 6.21.0 debug: 4.3.4 eslint: 8.57.0 - typescript: 5.4.3 + typescript: 5.4.4 transitivePeerDependencies: - supports-color dev: true @@ -3138,7 +3144,7 @@ packages: '@typescript-eslint/visitor-keys': 6.21.0 dev: true - /@typescript-eslint/type-utils@6.21.0(eslint@8.57.0)(typescript@5.4.3): + /@typescript-eslint/type-utils@6.21.0(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -3148,12 +3154,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.3) - '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.4) + '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.4) debug: 4.3.4 eslint: 8.57.0 - ts-api-utils: 1.3.0(typescript@5.4.3) - typescript: 5.4.3 + ts-api-utils: 1.3.0(typescript@5.4.4) + typescript: 5.4.4 transitivePeerDependencies: - supports-color dev: true @@ -3168,7 +3174,7 @@ packages: engines: {node: ^16.0.0 || >=18.0.0} dev: true - /@typescript-eslint/typescript-estree@5.62.0(typescript@5.4.3): + /@typescript-eslint/typescript-estree@5.62.0(typescript@5.4.4): resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3183,13 +3189,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.0 - tsutils: 3.21.0(typescript@5.4.3) - typescript: 5.4.3 + tsutils: 3.21.0(typescript@5.4.4) + typescript: 5.4.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/typescript-estree@6.21.0(typescript@5.4.3): + /@typescript-eslint/typescript-estree@6.21.0(typescript@5.4.4): resolution: {integrity: sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -3205,13 +3211,13 @@ packages: is-glob: 4.0.3 minimatch: 9.0.3 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.4.3) - typescript: 5.4.3 + ts-api-utils: 1.3.0(typescript@5.4.4) + typescript: 5.4.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.57.0)(typescript@5.4.3): + /@typescript-eslint/utils@5.62.0(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3222,7 +3228,7 @@ packages: '@types/semver': 7.5.8 '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 - '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.4.3) + '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.4.4) eslint: 8.57.0 eslint-scope: 5.1.1 semver: 7.6.0 @@ -3231,7 +3237,7 @@ packages: - typescript dev: true - /@typescript-eslint/utils@6.21.0(eslint@8.57.0)(typescript@5.4.3): + /@typescript-eslint/utils@6.21.0(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -3242,7 +3248,7 @@ packages: '@types/semver': 7.5.8 '@typescript-eslint/scope-manager': 6.21.0 '@typescript-eslint/types': 6.21.0 - '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.3) + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.4) eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: @@ -3423,7 +3429,7 @@ packages: engines: {node: '>=14'} dev: true - /@wordpress/eslint-plugin@17.11.0(@babel/core@7.24.3)(eslint@8.57.0)(prettier@3.2.5)(typescript@5.4.3): + /@wordpress/eslint-plugin@17.11.0(@babel/core@7.24.3)(eslint@8.57.0)(prettier@3.2.5)(typescript@5.4.4): resolution: {integrity: sha512-r4fNZskTmb+v2ewzkO9BYe+9rasY4vwqQw7Zs77nuBtZOjJLCY0eX5AsnwnZNz7rq/ClRx93PaL5fvVRkT2smA==} engines: {node: '>=14', npm: '>=6.14.4'} peerDependencies: @@ -3439,15 +3445,15 @@ packages: dependencies: '@babel/core': 7.24.3 '@babel/eslint-parser': 7.24.1(@babel/core@7.24.3)(eslint@8.57.0) - '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.3) - '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.4) '@wordpress/babel-preset-default': 7.38.0 '@wordpress/prettier-config': 3.11.0(prettier@3.2.5) cosmiconfig: 7.1.0 eslint: 8.57.0 eslint-config-prettier: 8.10.0(eslint@8.57.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0)(eslint@8.57.0) - eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.3) + eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.4) eslint-plugin-jsdoc: 46.10.1(eslint@8.57.0) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0) eslint-plugin-playwright: 0.15.3(eslint-plugin-jest@27.9.0)(eslint@8.57.0) @@ -3457,7 +3463,7 @@ packages: globals: 13.24.0 prettier: 3.2.5 requireindex: 1.2.0 - typescript: 5.4.3 + typescript: 5.4.4 transitivePeerDependencies: - '@types/eslint' - eslint-import-resolver-typescript @@ -4532,7 +4538,7 @@ packages: /core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.30)(cosmiconfig@9.0.0)(typescript@5.4.3): + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.30)(cosmiconfig@9.0.0)(typescript@5.4.4): resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} engines: {node: '>=v16'} peerDependencies: @@ -4541,9 +4547,9 @@ packages: typescript: '>=4' dependencies: '@types/node': 20.11.30 - cosmiconfig: 9.0.0(typescript@5.4.3) + cosmiconfig: 9.0.0(typescript@5.4.4) jiti: 1.21.0 - typescript: 5.4.3 + typescript: 5.4.4 dev: true /cosmiconfig@7.1.0: @@ -4556,7 +4562,7 @@ packages: path-type: 4.0.0 yaml: 1.10.2 - /cosmiconfig@9.0.0(typescript@5.4.3): + /cosmiconfig@9.0.0(typescript@5.4.4): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} peerDependencies: @@ -4569,7 +4575,7 @@ packages: import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 - typescript: 5.4.3 + typescript: 5.4.4 dev: true /create-ecdh@4.0.4: @@ -5418,7 +5424,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.4) debug: 3.2.7 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 @@ -5436,7 +5442,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.4.4) array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 array.prototype.flat: 1.3.2 @@ -5461,7 +5467,7 @@ packages: - supports-color dev: true - /eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.3): + /eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -5474,8 +5480,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.3) - '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.4) eslint: 8.57.0 transitivePeerDependencies: - supports-color @@ -5537,7 +5543,7 @@ packages: optional: true dependencies: eslint: 8.57.0 - eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.3) + eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(typescript@5.4.4) dev: true /eslint-plugin-prettier@5.1.3(eslint-config-prettier@8.10.0)(eslint@8.57.0)(prettier@3.2.5): @@ -5618,14 +5624,14 @@ packages: string.prototype.matchall: 4.0.11 dev: true - /eslint-plugin-storybook@0.8.0(eslint@8.57.0)(typescript@5.4.3): + /eslint-plugin-storybook@0.8.0(eslint@8.57.0)(typescript@5.4.4): resolution: {integrity: sha512-CZeVO5EzmPY7qghO2t64oaFM+8FTaD4uzOEjHKp516exyTKo+skKAL9GI3QALS2BXhyALJjNtwbmr1XinGE8bA==} engines: {node: '>= 18'} peerDependencies: eslint: '>=6' dependencies: '@storybook/csf': 0.0.1 - '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.4) eslint: 8.57.0 requireindex: 1.2.0 ts-dedent: 2.2.0 @@ -6048,7 +6054,7 @@ packages: cross-spawn: 7.0.3 signal-exit: 4.1.0 - /fork-ts-checker-webpack-plugin@8.0.0(typescript@5.4.3)(webpack@5.91.0): + /fork-ts-checker-webpack-plugin@8.0.0(typescript@5.4.4)(webpack@5.91.0): resolution: {integrity: sha512-mX3qW3idpueT2klaQXBzrIM/pHw+T0B/V9KHEvNrqijTq9NFnMZU6oreVxDYcf33P8a5cW+67PjodNHthGnNVg==} engines: {node: '>=12.13.0', yarn: '>=1.0.0'} peerDependencies: @@ -6067,7 +6073,7 @@ packages: schema-utils: 3.3.0 semver: 7.6.0 tapable: 2.2.1 - typescript: 5.4.3 + typescript: 5.4.4 webpack: 5.91.0(@swc/core@1.4.11)(esbuild@0.20.2)(webpack-cli@4.10.0) dev: true @@ -9624,6 +9630,11 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + /source-map@0.7.4: + resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} + engines: {node: '>= 8'} + dev: true + /space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} dev: true @@ -9906,10 +9917,10 @@ packages: peerDependencies: stylelint: ^16.0.0 dependencies: - stylelint: 16.3.0(typescript@5.4.3) + stylelint: 16.3.0(typescript@5.4.4) dev: true - /stylelint@16.3.0(typescript@5.4.3): + /stylelint@16.3.0(typescript@5.4.4): resolution: {integrity: sha512-hqC6xNTbQ5HRGQXfIW4HwXcx09raIFz4W4XFbraeqWqYRVVY/ibYvI0dsu0ORMQY8re2bpDdCAeIa2cm+QJ4Sw==} engines: {node: '>=18.12.0'} hasBin: true @@ -9921,7 +9932,7 @@ packages: '@dual-bundle/import-meta-resolve': 4.0.0 balanced-match: 2.0.0 colord: 2.9.3 - cosmiconfig: 9.0.0(typescript@5.4.3) + cosmiconfig: 9.0.0(typescript@5.4.4) css-functions-list: 3.2.1 css-tree: 2.3.1 debug: 4.3.4 @@ -10278,13 +10289,13 @@ packages: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: true - /ts-api-utils@1.3.0(typescript@5.4.3): + /ts-api-utils@1.3.0(typescript@5.4.4): resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} peerDependencies: typescript: '>=4.2.0' dependencies: - typescript: 5.4.3 + typescript: 5.4.4 dev: true /ts-dedent@2.2.0: @@ -10296,6 +10307,22 @@ packages: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} dev: false + /ts-loader@9.5.1(typescript@5.4.4)(webpack@5.91.0): + resolution: {integrity: sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg==} + engines: {node: '>=12.0.0'} + peerDependencies: + typescript: '*' + webpack: ^5.0.0 + dependencies: + chalk: 4.1.2 + enhanced-resolve: 5.16.0 + micromatch: 4.0.5 + semver: 7.6.0 + source-map: 0.7.4 + typescript: 5.4.4 + webpack: 5.91.0(@swc/core@1.4.11)(esbuild@0.20.2)(webpack-cli@4.10.0) + dev: true + /tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} dependencies: @@ -10312,14 +10339,14 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - /tsutils@3.21.0(typescript@5.4.3): + /tsutils@3.21.0(typescript@5.4.4): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 5.4.3 + typescript: 5.4.4 dev: true /tty-browserify@0.0.0: @@ -10429,8 +10456,8 @@ packages: possible-typed-array-names: 1.0.0 dev: true - /typescript@5.4.3: - resolution: {integrity: sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==} + /typescript@5.4.4: + resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==} engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4d5d691 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + }, + "include": ["assets/scripts/**/*"] +} diff --git a/webpack.mix.js b/webpack.mix.js index 10928a7..4637cea 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -46,13 +46,22 @@ if (fs.existsSync(scriptsVendorDir)) { }); } -if (fs.existsSync(scriptsDir)) { - discover(['src/blocks', scriptsDir], '.js', ['vendor']) - .filter((file) => !file.endsWith('stories.js')) // Exclude files ending with 'stories.js' - .forEach((file) => { - mix.js(file, 'scripts'); - }); -} +discover(['src/blocks', scriptsDir], '.ts').forEach((file) => { + mix.js(file, 'scripts').webpackConfig({ + module: { + rules: [ + { + test: /\.ts?$/, + loader: 'ts-loader', + exclude: /node_modules/, + }, + ], + }, + resolve: { + extensions: ['.js', '.ts'], + }, + }); +}); if (fs.existsSync(stylesDir)) { discover(['assets/styles'], '.css').forEach((file) => {