From e5c25e67a4843da29b3fc30eb410e57d49f1c60e Mon Sep 17 00:00:00 2001 From: Freddy L Date: Mon, 2 Oct 2023 23:00:33 -0400 Subject: [PATCH] Updated animelist-auth-sveltekit to use js extension for esm --- .../entrypoints.script.mts | 6 +- packages/animelist-auth-sveltekit/esbuild.mts | 2 +- .../animelist-auth-sveltekit/package.json | 10 +- .../src/client/index.ts | 2 +- .../animelist-auth-sveltekit/tsconfig.json | 2 + pnpm-lock.yaml | 106 ++++++++++++------ scripts/entrypoints.mts | 43 +++++-- scripts/esbuildProject.mts | 4 +- 8 files changed, 118 insertions(+), 57 deletions(-) diff --git a/packages/animelist-auth-sveltekit/entrypoints.script.mts b/packages/animelist-auth-sveltekit/entrypoints.script.mts index 049659b..5640a55 100644 --- a/packages/animelist-auth-sveltekit/entrypoints.script.mts +++ b/packages/animelist-auth-sveltekit/entrypoints.script.mts @@ -3,4 +3,8 @@ import path from "path"; import { fileURLToPath } from "url"; const packageDir = path.dirname(fileURLToPath(import.meta.url)); -generateEntrypoints({ packageDir }) \ No newline at end of file +generateEntrypoints({ + packageDir, + formats: ['esm'], + convertJsToEsm: false +}) \ No newline at end of file diff --git a/packages/animelist-auth-sveltekit/esbuild.mts b/packages/animelist-auth-sveltekit/esbuild.mts index f5975dd..dc6c245 100644 --- a/packages/animelist-auth-sveltekit/esbuild.mts +++ b/packages/animelist-auth-sveltekit/esbuild.mts @@ -8,6 +8,6 @@ await esbuildProject({ inputs: ["src/**/*.ts"], exclude: ["**/*.test.ts"], formats: ['esm'], - //outExtensions: {}, // to override .mjs extension + outExtensions: {}, // do not overwrite .mjs extensions packageDir, }); diff --git a/packages/animelist-auth-sveltekit/package.json b/packages/animelist-auth-sveltekit/package.json index 0822976..f3c0363 100644 --- a/packages/animelist-auth-sveltekit/package.json +++ b/packages/animelist-auth-sveltekit/package.json @@ -3,7 +3,7 @@ "version": "0.0.1-alpha.4", "description": "Integration with the @animelist/auth for SvelteKit", "type": "module", - "module": "dist/index.mjs", + "module": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { "typecheck": "tsc --noEmit", @@ -35,12 +35,12 @@ "exports": { "./package.json": "./package.json", "./client": { - "import": "./dist/client/index.mjs", - "default": "./dist/client/index.mjs" + "import": "./dist/client/index.js", + "default": "./dist/client/index.js" }, "./server": { - "import": "./dist/server/index.mjs", - "default": "./dist/server/index.mjs" + "import": "./dist/server/index.js", + "default": "./dist/server/index.js" } }, "files": [ diff --git a/packages/animelist-auth-sveltekit/src/client/index.ts b/packages/animelist-auth-sveltekit/src/client/index.ts index a221389..db9b40a 100644 --- a/packages/animelist-auth-sveltekit/src/client/index.ts +++ b/packages/animelist-auth-sveltekit/src/client/index.ts @@ -1,4 +1,4 @@ -export * from "./session"; +export * from "./session.js"; // Re-export client related stuff export { diff --git a/packages/animelist-auth-sveltekit/tsconfig.json b/packages/animelist-auth-sveltekit/tsconfig.json index f807cea..d0bae46 100644 --- a/packages/animelist-auth-sveltekit/tsconfig.json +++ b/packages/animelist-auth-sveltekit/tsconfig.json @@ -8,5 +8,7 @@ "outDir": "./dist", "declarationDir": "dist", "emitDeclarationOnly": true, + "module": "NodeNext", + "moduleResolution": "NodeNext" }, } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b803f0..c4b33e5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -224,9 +224,6 @@ importers: '@animelist/core': specifier: workspace:* version: link:../animelist-core - next: - specifier: ^13.5.2 - version: 13.5.2(react-dom@18.2.0)(react@18.2.0) react: specifier: ^18.2.0 version: 18.2.0 @@ -243,6 +240,9 @@ importers: ncp: specifier: ^2.0.0 version: 2.0.0 + next: + specifier: ^13.5.2 + version: 13.5.2(react-dom@18.2.0)(react@18.2.0) typescript: specifier: ^5.2.2 version: 5.2.2 @@ -258,13 +258,13 @@ importers: '@animelist/core': specifier: workspace:* version: link:../animelist-core - '@sveltejs/kit': - specifier: ^1.25.0 - version: 1.25.0(svelte@4.2.1)(vite@4.4.9) svelte: specifier: ^4.0.5 version: 4.2.1 devDependencies: + '@sveltejs/kit': + specifier: ^1.25.0 + version: 1.25.0(svelte@4.2.1)(vite@4.4.9) eslint: specifier: ^8.49.0 version: 8.49.0 @@ -273,10 +273,6 @@ importers: version: 5.2.2 packages/animelist-client: - dependencies: - eslint: - specifier: ^8.49.0 - version: 8.49.0 devDependencies: '@animelist/core': specifier: workspace:* @@ -284,19 +280,21 @@ importers: esbuild: specifier: ^0.19.3 version: 0.19.3 + eslint: + specifier: ^8.49.0 + version: 8.49.0 typescript: specifier: 5.2.2 version: 5.2.2 packages/animelist-core: - dependencies: - eslint: - specifier: ^8.49.0 - version: 8.49.0 devDependencies: esbuild: specifier: ^0.19.3 version: 0.19.3 + eslint: + specifier: ^8.49.0 + version: 8.49.0 typescript: specifier: 5.2.2 version: 5.2.2 @@ -355,6 +353,7 @@ packages: cpu: [arm64] os: [android] requiresBuild: true + dev: true optional: true /@esbuild/android-arm64@0.19.3: @@ -372,6 +371,7 @@ packages: cpu: [arm] os: [android] requiresBuild: true + dev: true optional: true /@esbuild/android-arm@0.19.3: @@ -389,6 +389,7 @@ packages: cpu: [x64] os: [android] requiresBuild: true + dev: true optional: true /@esbuild/android-x64@0.19.3: @@ -406,6 +407,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: true optional: true /@esbuild/darwin-arm64@0.19.3: @@ -423,6 +425,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: true optional: true /@esbuild/darwin-x64@0.19.3: @@ -440,6 +443,7 @@ packages: cpu: [arm64] os: [freebsd] requiresBuild: true + dev: true optional: true /@esbuild/freebsd-arm64@0.19.3: @@ -457,6 +461,7 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true + dev: true optional: true /@esbuild/freebsd-x64@0.19.3: @@ -474,6 +479,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-arm64@0.19.3: @@ -491,6 +497,7 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-arm@0.19.3: @@ -508,6 +515,7 @@ packages: cpu: [ia32] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-ia32@0.19.3: @@ -525,6 +533,7 @@ packages: cpu: [loong64] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-loong64@0.19.3: @@ -542,6 +551,7 @@ packages: cpu: [mips64el] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-mips64el@0.19.3: @@ -559,6 +569,7 @@ packages: cpu: [ppc64] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-ppc64@0.19.3: @@ -576,6 +587,7 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-riscv64@0.19.3: @@ -593,6 +605,7 @@ packages: cpu: [s390x] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-s390x@0.19.3: @@ -610,6 +623,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@esbuild/linux-x64@0.19.3: @@ -627,6 +641,7 @@ packages: cpu: [x64] os: [netbsd] requiresBuild: true + dev: true optional: true /@esbuild/netbsd-x64@0.19.3: @@ -644,6 +659,7 @@ packages: cpu: [x64] os: [openbsd] requiresBuild: true + dev: true optional: true /@esbuild/openbsd-x64@0.19.3: @@ -661,6 +677,7 @@ packages: cpu: [x64] os: [sunos] requiresBuild: true + dev: true optional: true /@esbuild/sunos-x64@0.19.3: @@ -678,6 +695,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: true optional: true /@esbuild/win32-arm64@0.19.3: @@ -695,6 +713,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: true optional: true /@esbuild/win32-ia32@0.19.3: @@ -712,6 +731,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: true optional: true /@esbuild/win32-x64@0.19.3: @@ -912,7 +932,7 @@ packages: /@next/env@13.5.2: resolution: {integrity: sha512-dUseBIQVax+XtdJPzhwww4GetTjlkRSsXeQnisIJWBaHsnxYcN2RGzsPHi58D6qnkATjnhuAtQTJmR1hKYQQPg==} - dev: false + dev: true /@next/env@13.5.3: resolution: {integrity: sha512-X4te86vsbjsB7iO4usY9jLPtZ827Mbx+WcwNBGUOIuswuTAKQtzsuoxc/6KLxCMvogKG795MhrR1LDhYgDvasg==} @@ -930,7 +950,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-darwin-arm64@13.5.3: @@ -948,7 +968,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-darwin-x64@13.5.3: @@ -966,7 +986,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-linux-arm64-gnu@13.5.3: @@ -984,7 +1004,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-linux-arm64-musl@13.5.3: @@ -1002,7 +1022,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-linux-x64-gnu@13.5.3: @@ -1020,7 +1040,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-linux-x64-musl@13.5.3: @@ -1038,7 +1058,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-win32-arm64-msvc@13.5.3: @@ -1056,7 +1076,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-win32-ia32-msvc@13.5.3: @@ -1074,7 +1094,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: false + dev: true optional: true /@next/swc-win32-x64-msvc@13.5.3: @@ -1432,6 +1452,7 @@ packages: /@polka/url@1.0.0-next.23: resolution: {integrity: sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==} + dev: true /@rushstack/eslint-patch@1.4.0: resolution: {integrity: sha512-cEjvTPU32OM9lUFegJagO0mRnIn+rbqrG89vV8/xLnLFX0DoR0r1oy5IlTga71Q7uT3Qus7qm7wgeiMT/+Irlg==} @@ -1509,6 +1530,7 @@ packages: vite: 4.4.9(@types/node@20.6.2) transitivePeerDependencies: - supports-color + dev: true /@sveltejs/vite-plugin-svelte-inspector@1.0.4(@sveltejs/vite-plugin-svelte@2.4.6)(svelte@4.2.1)(vite@4.4.9): resolution: {integrity: sha512-zjiuZ3yydBtwpF3bj0kQNV0YXe+iKE545QGZVTaylW3eAzFr+pJ/cwK8lZEaRp4JtaJXhD5DyWAV4AxLh6DgaQ==} @@ -1524,6 +1546,7 @@ packages: vite: 4.4.9(@types/node@20.6.2) transitivePeerDependencies: - supports-color + dev: true /@sveltejs/vite-plugin-svelte@2.4.6(svelte@4.2.1)(vite@4.4.9): resolution: {integrity: sha512-zO79p0+DZnXPnF0ltIigWDx/ux7Ni+HRaFOw720Qeivc1azFUrJxTl0OryXVibYNx1hCboGia1NRV3x8RNv4cA==} @@ -1543,12 +1566,12 @@ packages: vitefu: 0.2.4(vite@4.4.9) transitivePeerDependencies: - supports-color + dev: true /@swc/helpers@0.5.2: resolution: {integrity: sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==} dependencies: tslib: 2.6.2 - dev: false /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} @@ -1580,6 +1603,7 @@ packages: /@types/cookie@0.5.2: resolution: {integrity: sha512-DBpRoJGKJZn7RY92dPrgoMew8xCWc2P71beqsjyhEI/Ds9mOyVmBwtekyfhpwFIVt1WrxTonFifiOZ62V8CnNA==} + dev: true /@types/eslint@8.44.3: resolution: {integrity: sha512-iM/WfkwAhwmPff3wZuPLYiHX18HI24jU8k1ZSH7P8FHwxTjZ2P6CoX2wnF43oprR+YXJM6UUxATkNvyv/JHd+g==} @@ -2486,7 +2510,6 @@ packages: /client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} - dev: false /cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} @@ -2797,6 +2820,7 @@ packages: /deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + dev: true /defaults@1.0.4: resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} @@ -2856,6 +2880,7 @@ packages: /devalue@4.3.2: resolution: {integrity: sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==} + dev: true /didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} @@ -3099,6 +3124,7 @@ packages: '@esbuild/win32-arm64': 0.18.20 '@esbuild/win32-ia32': 0.18.20 '@esbuild/win32-x64': 0.18.20 + dev: true /esbuild@0.19.3: resolution: {integrity: sha512-UlJ1qUUA2jL2nNib1JTSkifQTcYTroFqRjwCFW4QYEKEsixXD5Tik9xML7zh2gTxkYTBKGHNH9y7txMwVyPbjw==} @@ -3420,6 +3446,7 @@ packages: /esm-env@1.0.0: resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} + dev: true /espree@9.6.1: resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} @@ -3795,7 +3822,6 @@ packages: /glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - dev: false /glob@10.3.7: resolution: {integrity: sha512-wCMbE1m9Nx5yD9LYtgsVWq5VhHlk5WzJirw594qZR6AIvQYuHrdDtIktUVjQItalD53y7dqoedu9xP0u0WaxIQ==} @@ -3887,6 +3913,7 @@ packages: /globalyzer@0.1.0: resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} + dev: true /globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} @@ -3901,6 +3928,7 @@ packages: /globrex@0.1.2: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + dev: true /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} @@ -4583,6 +4611,7 @@ packages: /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} + dev: true /known-css-properties@0.28.0: resolution: {integrity: sha512-9pSL5XB4J+ifHP0e0jmmC98OGC1nL8/JjS+fi6mnTlIf//yt/MfVLtKg7S6nCtj/8KTcWX7nRlY0XywoYY1ISQ==} @@ -4817,7 +4846,6 @@ packages: hasBin: true dependencies: js-tokens: 4.0.0 - dev: false /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} @@ -4953,6 +4981,7 @@ packages: resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} engines: {node: '>=10.0.0'} hasBin: true + dev: true /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} @@ -5114,10 +5143,12 @@ packages: /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} + dev: true /mrmime@1.0.1: resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} engines: {node: '>=10'} + dev: true /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} @@ -5212,7 +5243,7 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros - dev: false + dev: true /next@13.5.3(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-4Nt4HRLYDW/yRpJ/QR2t1v63UOMS55A38dnWv3UDOWGezuY0ZyFO1ABNbD7mulVzs9qVhgy2+ppjdsANpKP1mg==} @@ -6007,7 +6038,6 @@ packages: nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 - dev: false /postcss@8.4.30: resolution: {integrity: sha512-7ZEao1g4kd68l97aWG/etQKPKq07us0ieSZ2TnFDk11i0ZfDW2AwKHYU8qv4MZKqN2fdBfg+7q0ES06UA73C1g==} @@ -6144,7 +6174,6 @@ packages: loose-envify: 1.4.0 react: 18.2.0 scheduler: 0.23.0 - dev: false /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} @@ -6159,7 +6188,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: loose-envify: 1.4.0 - dev: false /read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} @@ -6389,6 +6417,7 @@ packages: hasBin: true optionalDependencies: fsevents: 2.3.3 + dev: true /run-async@2.4.1: resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==} @@ -6411,6 +6440,7 @@ packages: engines: {node: '>=6'} dependencies: mri: 1.2.0 + dev: true /safe-array-concat@1.0.1: resolution: {integrity: sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==} @@ -6455,7 +6485,6 @@ packages: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} dependencies: loose-envify: 1.4.0 - dev: false /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} @@ -6488,6 +6517,7 @@ packages: /set-cookie-parser@2.6.0: resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} + dev: true /set-function-name@2.0.1: resolution: {integrity: sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==} @@ -6557,6 +6587,7 @@ packages: '@polka/url': 1.0.0-next.23 mrmime: 1.0.1 totalist: 3.0.1 + dev: true /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} @@ -6828,7 +6859,6 @@ packages: dependencies: client-only: 0.0.1 react: 18.2.0 - dev: false /sucrase@3.34.0: resolution: {integrity: sha512-70/LQEZ07TEcxiU2dz51FKaE6hCTWC6vr7FOk3Gr0U60C3shtAN+H+BFr9XlYe5xqf3RA8nrc+VIwzCfnxuXJw==} @@ -6917,6 +6947,7 @@ packages: svelte: ^3.19.0 || ^4.0.0 dependencies: svelte: 4.2.1 + dev: true /svelte-preprocess@5.0.4(postcss@8.4.30)(svelte@4.2.1)(typescript@5.2.2): resolution: {integrity: sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==} @@ -7082,6 +7113,7 @@ packages: dependencies: globalyzer: 0.1.0 globrex: 0.1.2 + dev: true /tinybench@2.5.1: resolution: {integrity: sha512-65NKvSuAVDP/n4CqH+a9w2kTlLReS9vhsAP06MWx+/89nMinJyB2icyl58RIcqCmIggpojIGeuJGhjU1aGMBSg==} @@ -7120,6 +7152,7 @@ packages: /totalist@3.0.1: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} + dev: true /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -7317,6 +7350,7 @@ packages: engines: {node: '>=14.0'} dependencies: busboy: 1.6.0 + dev: true /unique-filename@3.0.0: resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} @@ -7449,6 +7483,7 @@ packages: rollup: 3.29.3 optionalDependencies: fsevents: 2.3.3 + dev: true /vitefu@0.2.4(vite@4.4.9): resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} @@ -7459,6 +7494,7 @@ packages: optional: true dependencies: vite: 4.4.9(@types/node@20.6.2) + dev: true /vitest@0.34.5: resolution: {integrity: sha512-CPI68mmnr2DThSB3frSuE5RLm9wo5wU4fbDrDwWQQB1CWgq9jQVoQwnQSzYAjdoBOPoH2UtXpOgHVge/uScfZg==} @@ -7549,7 +7585,6 @@ packages: dependencies: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 - dev: false /wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} @@ -7786,7 +7821,6 @@ packages: /zod@3.21.4: resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} - dev: false /zod@3.22.2: resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==} diff --git a/scripts/entrypoints.mts b/scripts/entrypoints.mts index 027be10..4a4f25f 100644 --- a/scripts/entrypoints.mts +++ b/scripts/entrypoints.mts @@ -12,12 +12,25 @@ function writeFileSync(filePath: string, contents: string) { fse.writeFileSync(filePath, contents) } +type JsFormat = 'cjs' | 'esm'; + type GenerateEntryPointsOptions = { packageDir: string; additionalInputs?: string[]; + formats?: JsFormat[], + convertJsToEsm?: boolean; } -export function generateEntrypoints({ packageDir, additionalInputs }: GenerateEntryPointsOptions) { +export function generateEntrypoints({ + packageDir, + additionalInputs, + formats = ['cjs', 'esm'], + convertJsToEsm = true }: GenerateEntryPointsOptions) { + + if (convertJsToEsm === false && formats.includes('cjs')) { + throw new Error("'convertJsToEsm' cannot false be used if the format include 'cjs'"); + } + const timestamp = new Date().toISOString(); const srcDir = path.resolve(packageDir, 'src'); @@ -62,25 +75,33 @@ export function generateEntrypoints({ packageDir, additionalInputs }: GenerateEn const resolvedModuleExport = path.join(resolvedImport, `${fileName}.js`).replace(/\\/g, '/'); const resolvedTypesExport = path.join(resolvedImport, `${fileName}.d.ts`).replace(/\\/g, '/'); - const commonJsExport = `module.exports = require("${resolvedModuleExport}")`; - const esmExport = `export * from "${resolvedModuleExport}"`.replace(".js", ".mjs"); const typesExport = `export * from "${resolvedTypesExport}"` - const commonJsEntryFilePath = path.join(packageDir, basePath, `index.js`); - const esmEntryFilePath = path.join(packageDir, basePath, `index.mjs`); + if (formats.includes('cjs')) { + const commonJsExport = `module.exports = require("${resolvedModuleExport}")`; + const commonJsEntryFilePath = path.join(packageDir, basePath, `index.js`); + writeFileSync(commonJsEntryFilePath, commonJsExport); + console.log({ commonJsExport, commonJsEntryFilePath }) + } + + if (formats.includes('esm')) { + const ext = convertJsToEsm ? "mjs" : "js"; + const esmExport = convertJsToEsm ? + `export * from "${resolvedModuleExport}"`.replace(/.js$/, ext) : + `export * from "${resolvedModuleExport}"`; + + const esmEntryFilePath = path.join(packageDir, basePath, `index.${ext}`); + writeFileSync(esmEntryFilePath, esmExport); + console.log({ esmExport, esmEntryFilePath }) + } + const typeEntryPointFilePath = path.join(packageDir, basePath, `index.d.ts`); const entryPointMarkerFilePath = path.join(packageDir, basePath, ENTRYPOINT_MARKER); - writeFileSync(commonJsEntryFilePath, commonJsExport); - writeFileSync(esmEntryFilePath, esmExport); writeFileSync(typeEntryPointFilePath, typesExport); writeFileSync(entryPointMarkerFilePath, timestamp); console.log({ - commonJsExport, - commonJsEntryFilePath, - esmExport, - esmEntryFilePath, typesExport, typeEntryPointFilePath }) diff --git a/scripts/esbuildProject.mts b/scripts/esbuildProject.mts index 8fc5b1e..4bc532a 100644 --- a/scripts/esbuildProject.mts +++ b/scripts/esbuildProject.mts @@ -32,7 +32,7 @@ export async function esbuildProject({ packageDir, exclude, inputs, ...rest }: B entryPoints, logLevel: 'debug', outdir, - sourcemap: true, + sourcemap: true, format: 'cjs', outExtension: rest.outExtensions }) @@ -46,7 +46,7 @@ export async function esbuildProject({ packageDir, exclude, inputs, ...rest }: B outdir, sourcemap: true, format: 'esm', - outExtension: rest.outExtensions || { + outExtension: rest.outExtensions ?? { ".js": ".mjs" } });