diff --git a/assets/cjs_shims.js b/assets/cjs_shims.js index ea603830..9342fe24 100644 --- a/assets/cjs_shims.js +++ b/assets/cjs_shims.js @@ -3,11 +3,12 @@ // if we export it as `const importMetaUrl = ... __filename ...` // But using a function will not cause this issue -const getImportMetaUrl = () => - typeof document === "undefined" - ? new URL(`file:${__filename}`).href - : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') - ? document.currentScript.src - : new URL("main.js", document.baseURI).href; +const getImportMetaUrl = () => + typeof document === 'undefined' + ? new URL(`file:${__filename}`).href + : document.currentScript && + document.currentScript.tagName.toUpperCase() === 'SCRIPT' + ? document.currentScript.src + : new URL('main.js', document.baseURI).href export const importMetaUrl = /* @__PURE__ */ getImportMetaUrl() diff --git a/docs/README.md b/docs/README.md index e9816cec..e095f33f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -615,6 +615,7 @@ When you use legacy TypeScript decorator by enabling `emitDecoratorMetadata` in decorators. In this case, you can give extra swc configuration in the `tsup.config.ts` file. For example, if you have to define `useDefineForClassFields`, you can do that as follows: + ```ts import { defineConfig } from 'tsup' @@ -626,10 +627,10 @@ export default defineConfig({ swc: { jsc: { transform: { - useDefineForClassFields: true - } - } - } + useDefineForClassFields: true, + }, + }, + }, }) ``` @@ -648,9 +649,9 @@ Note: some SWC options cannot be configured: "keepClassNames": true, "target": "es2022" } - ``` +``` -You can also define a custom `.swcrc` configuration file. Just set `swcrc` to `true` +You can also define a custom `.swcrc` configuration file. Just set `swcrc` to `true` in `tsup.config.ts` to allow SWC plugin to discover automatically your custom swc config file. ```ts @@ -662,8 +663,8 @@ export default defineConfig({ sourcemap: true, clean: true, swc: { - swcrc: true - } + swcrc: true, + }, }) ``` diff --git a/package.json b/package.json index 7b19f0be..8e4e8a24 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "rollup-plugin-dts": "6.1.1", "sass": "1.85.0", "strip-json-comments": "5.0.1", - "svelte": "5.19.9", + "svelte": "5.51.5", "svelte-preprocess": "6.0.3", "terser": "^5.39.0", "ts-essentials": "10.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f9b79e4..bb3715ef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,11 +106,11 @@ importers: specifier: 5.0.1 version: 5.0.1 svelte: - specifier: 5.19.9 - version: 5.19.9 + specifier: 5.51.5 + version: 5.51.5 svelte-preprocess: specifier: 6.0.3 - version: 6.0.3(postcss-load-config@6.0.1(jiti@2.6.1)(postcss@8.5.2)(yaml@2.8.1))(postcss@8.5.2)(sass@1.85.0)(svelte@5.19.9)(typescript@5.7.3) + version: 6.0.3(postcss-load-config@6.0.1(jiti@2.6.1)(postcss@8.5.2)(yaml@2.8.1))(postcss@8.5.2)(sass@1.85.0)(svelte@5.51.5)(typescript@5.7.3) terser: specifier: ^5.39.0 version: 5.44.1 @@ -132,10 +132,6 @@ importers: packages: - '@ampproject/remapping@2.3.0': - resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} - engines: {node: '>=6.0.0'} - '@babel/code-frame@7.27.1': resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==} engines: {node: '>=6.9.0'} @@ -621,6 +617,9 @@ packages: '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -891,6 +890,11 @@ packages: '@rushstack/ts-command-line@5.1.3': resolution: {integrity: sha512-Kdv0k/BnnxIYFlMVC1IxrIS0oGQd4T4b7vKfx52Y2+wk2WZSDFIvedr7JrhenzSlm3ou5KwtoTGTGd5nbODRug==} + '@sveltejs/acorn-typescript@1.0.9': + resolution: {integrity: sha512-lVJX6qEgs/4DOcRTpo56tmKzVPtoWAaVbL4hfO7t7NVwl9AAXzQR6cihesW1BmNMPl+bK6dreu2sOKBP2Q9CIA==} + peerDependencies: + acorn: ^8.9.0 + '@swc/core-darwin-arm64@1.10.18': resolution: {integrity: sha512-FdGqzAIKVQJu8ROlnHElP59XAUsUzCFSNsou+tY/9ba+lhu8R9v0OI5wXiPErrKGZpQFMmx/BPqqhx3X4SuGNg==} engines: {node: '>=10'} @@ -984,6 +988,9 @@ packages: '@types/resolve@1.20.6': resolution: {integrity: sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==} + '@types/trusted-types@2.0.7': + resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + '@vitest/expect@3.0.6': resolution: {integrity: sha512-zBduHf/ja7/QRX4HdP1DSq5XrPgdN+jzLOwaTq/0qZjYfgETNFCKf9nOAp2j3hmom3oTbczuUzrzg9Hafh7hNg==} @@ -1016,11 +1023,6 @@ packages: '@vitest/utils@3.0.6': resolution: {integrity: sha512-18ktZpf4GQFTbf9jK543uspU03Q2qya7ZGya5yiZ0Gx0nnnalBvd5ZBislbl2EhLjM8A8rt4OilqKG7QwcGkvQ==} - acorn-typescript@1.4.13: - resolution: {integrity: sha512-xsc9Xv0xlVfwp2o7sQ+GCQ1PgbkdcpWdTzrwXxO3xDMTAywVS3oXVOcOHuRjAPkS4P9b+yc/qNF15460v+jp4Q==} - peerDependencies: - acorn: '>=8.9.0' - acorn@8.15.0: resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} engines: {node: '>=0.4.0'} @@ -1196,6 +1198,9 @@ packages: engines: {node: '>=0.10'} hasBin: true + devalue@5.6.3: + resolution: {integrity: sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==} + diff@8.0.2: resolution: {integrity: sha512-sSuxWU5j5SR9QQji/o2qMvqRNYRDOcBTgsJ/DeCf4iSN4gW+gNMXM7wFIP+fdXZxoNiAnHUTGjCr+TSWXdRDKg==} engines: {node: '>=0.3.1'} @@ -1238,8 +1243,8 @@ packages: esm-env@1.2.2: resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==} - esrap@1.4.9: - resolution: {integrity: sha512-3OMlcd0a03UGuZpPeUC1HxR3nA23l+HEyCiZw3b3FumJIN9KphoGzDJKMXI1S72jVS1dsenDyQC0kJlO1U9E1g==} + esrap@2.2.3: + resolution: {integrity: sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==} estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} @@ -1300,6 +1305,7 @@ packages: glob@10.4.5: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me hasBin: true graceful-fs@4.2.11: @@ -1711,8 +1717,8 @@ packages: typescript: optional: true - svelte@5.19.9: - resolution: {integrity: sha512-860s752/ZZxHIsii31ELkdKBOCeAuDsfb/AGUXJyQyzUVLRSt4oqEw/BV5+2+mNg8mbqmD3OK+vMvwWMPM6f8A==} + svelte@5.51.5: + resolution: {integrity: sha512-/4tR5cLsWOgH3wnNRXnFoWaJlwPGbJanZPSKSD6nHM2y01dvXeEF4Nx7jevoZ+UpJpkIHh6mY2tqDncuI4GHng==} engines: {node: '>=18'} terser@5.44.1: @@ -1930,11 +1936,6 @@ packages: snapshots: - '@ampproject/remapping@2.3.0': - dependencies: - '@jridgewell/gen-mapping': 0.3.13 - '@jridgewell/trace-mapping': 0.3.31 - '@babel/code-frame@7.27.1': dependencies: '@babel/helper-validator-identifier': 7.28.5 @@ -2196,6 +2197,11 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/trace-mapping': 0.3.31 + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/source-map@0.3.11': @@ -2429,6 +2435,10 @@ snapshots: transitivePeerDependencies: - '@types/node' + '@sveltejs/acorn-typescript@1.0.9(acorn@8.15.0)': + dependencies: + acorn: 8.15.0 + '@swc/core-darwin-arm64@1.10.18': optional: true @@ -2497,6 +2507,8 @@ snapshots: '@types/resolve@1.20.6': {} + '@types/trusted-types@2.0.7': {} + '@vitest/expect@3.0.6': dependencies: '@vitest/spy': 3.0.6 @@ -2541,10 +2553,6 @@ snapshots: loupe: 3.2.1 tinyrainbow: 2.0.0 - acorn-typescript@1.4.13(acorn@8.15.0): - dependencies: - acorn: 8.15.0 - acorn@8.15.0: {} ajv-draft-04@1.0.0(ajv@8.13.0): @@ -2706,6 +2714,8 @@ snapshots: detect-libc@1.0.3: optional: true + devalue@5.6.3: {} + diff@8.0.2: {} dotenv@17.2.3: {} @@ -2808,7 +2818,7 @@ snapshots: esm-env@1.2.2: {} - esrap@1.4.9: + esrap@2.2.3: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -3217,27 +3227,29 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-preprocess@6.0.3(postcss-load-config@6.0.1(jiti@2.6.1)(postcss@8.5.2)(yaml@2.8.1))(postcss@8.5.2)(sass@1.85.0)(svelte@5.19.9)(typescript@5.7.3): + svelte-preprocess@6.0.3(postcss-load-config@6.0.1(jiti@2.6.1)(postcss@8.5.2)(yaml@2.8.1))(postcss@8.5.2)(sass@1.85.0)(svelte@5.51.5)(typescript@5.7.3): dependencies: - svelte: 5.19.9 + svelte: 5.51.5 optionalDependencies: postcss: 8.5.2 postcss-load-config: 6.0.1(jiti@2.6.1)(postcss@8.5.2)(yaml@2.8.1) sass: 1.85.0 typescript: 5.7.3 - svelte@5.19.9: + svelte@5.51.5: dependencies: - '@ampproject/remapping': 2.3.0 + '@jridgewell/remapping': 2.3.5 '@jridgewell/sourcemap-codec': 1.5.5 + '@sveltejs/acorn-typescript': 1.0.9(acorn@8.15.0) '@types/estree': 1.0.8 + '@types/trusted-types': 2.0.7 acorn: 8.15.0 - acorn-typescript: 1.4.13(acorn@8.15.0) aria-query: 5.3.2 axobject-query: 4.1.0 clsx: 2.1.1 + devalue: 5.6.3 esm-env: 1.2.2 - esrap: 1.4.9 + esrap: 2.2.3 is-reference: 3.0.3 locate-character: 3.0.0 magic-string: 0.30.21 diff --git a/src/esbuild/swc.ts b/src/esbuild/swc.ts index 755009d3..ee12c1dc 100644 --- a/src/esbuild/swc.ts +++ b/src/esbuild/swc.ts @@ -9,7 +9,10 @@ import type { Logger } from '../log' export type SwcPluginConfig = { logger: Logger } & Options -export const swcPlugin = ({ logger, ...swcOptions }: SwcPluginConfig): Plugin => { +export const swcPlugin = ({ + logger, + ...swcOptions +}: SwcPluginConfig): Plugin => { return { name: 'swc', diff --git a/src/options.ts b/src/options.ts index 6bbee23b..7f68bd8c 100644 --- a/src/options.ts +++ b/src/options.ts @@ -257,8 +257,8 @@ export type Options = { * @default true */ removeNodeProtocol?: boolean - - swc?: SwcPluginConfig; + + swc?: SwcPluginConfig } export interface NormalizedExperimentalDtsConfig { diff --git a/vitest.config.mts b/vitest.config.mts index 8f6d3ac6..7e032eda 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -4,6 +4,6 @@ export default defineConfig({ test: { testTimeout: 50000, globalSetup: 'vitest-global.ts', - include: ["test/*.test.ts", "src/**/*.test.ts"] + include: ['test/*.test.ts', 'src/**/*.test.ts'], }, })