diff --git a/package.json b/package.json index 719a184..e62b98b 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "svelte": "^3.49.0", "svelte-preprocess": "^4.10.7", "svelte2tsx": "^0.5.11", - "tsdv": "^0.4.0", + "tsdv": "^0.5.0", "typescript": "^4.7.4", - "vite": "^2.9.12" + "vite": "^2.9.13" }, "packageManager": "pnpm@7.1.9", "bundlewatch": { diff --git a/packages/bytemd/tsdv.config.mjs b/packages/bytemd/tsdv.config.ts similarity index 51% rename from packages/bytemd/tsdv.config.mjs rename to packages/bytemd/tsdv.config.ts index f87e40f..e14cd89 100644 --- a/packages/bytemd/tsdv.config.mjs +++ b/packages/bytemd/tsdv.config.ts @@ -1,19 +1,22 @@ -// @ts-check import { defineConfig } from 'tsdv' import { svelte } from '@sveltejs/vite-plugin-svelte' -import { alias, sveltePreprocessor } from '../../scripts/build.mjs' +import { getAlias, sveltePreprocessor } from '../../scripts/build.mjs' // nullish coalescing in es2020 export default defineConfig({ target: 'es2019', tsc: false, - vite: { - resolve: { alias }, - plugins: [ - svelte({ - preprocess: [sveltePreprocessor], - }), - ], + vite({ format }) { + return { + resolve: { + alias: getAlias(format), + }, + plugins: [ + svelte({ + preprocess: [sveltePreprocessor], + }), + ], + } }, test: { globals: true, diff --git a/packages/plugin-gfm/tsdv.config.ts b/packages/plugin-gfm/tsdv.config.ts index a346d90..46c63db 100644 --- a/packages/plugin-gfm/tsdv.config.ts +++ b/packages/plugin-gfm/tsdv.config.ts @@ -1,10 +1,14 @@ import { defineConfig } from 'tsdv' -import { alias } from '../../scripts/build.mjs' +import { getAlias } from '../../scripts/build.mjs' export default defineConfig({ target: 'es2019', tsc: false, - vite: { - resolve: { alias }, + vite({ format }) { + return { + resolve: { + alias: getAlias(format), + }, + } }, }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d009af..2cff4b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,9 +27,9 @@ importers: svelte: ^3.49.0 svelte-preprocess: ^4.10.7 svelte2tsx: ^0.5.11 - tsdv: ^0.4.0 + tsdv: ^0.5.0 typescript: ^4.7.4 - vite: ^2.9.12 + vite: ^2.9.13 devDependencies: '@sveltejs/vite-plugin-svelte': 1.0.0-next.49_svelte@3.49.0+vite@2.9.13 '@testing-library/jest-dom': 5.16.4 @@ -54,7 +54,7 @@ importers: svelte: 3.49.0 svelte-preprocess: 4.10.7_ti5n7ksfdoivvzciqy5qn6uyye svelte2tsx: 0.5.11_uslzfc62di2n2otc2tvfklnwji - tsdv: 0.4.0_jsdom@20.0.0+sass@1.53.0 + tsdv: 0.5.0_jsdom@20.0.0+sass@1.53.0 typescript: 4.7.4 vite: 2.9.13_sass@1.53.0 @@ -803,19 +803,19 @@ packages: '@jridgewell/sourcemap-codec': 1.4.13 dev: true - /@microsoft/api-extractor-model/7.20.3: - resolution: {integrity: sha512-RhPRSAXIafeq90D2uBIU19+QPXF/ZC2AucB0+RCVMoioMmhUDwzd5EQcIDHI3NXps8ojj+Xu3cg/IwaqbCnX0w==} + /@microsoft/api-extractor-model/7.21.0: + resolution: {integrity: sha512-NN4mXzoQWTuzznIcnLWeV6tGyn6Os9frDK6M/mmTXZ73vUYOvSWoKQ5SYzyzP7HF3YtvTmr1Rs+DsBb0HRx7WQ==} dependencies: '@microsoft/tsdoc': 0.14.1 '@microsoft/tsdoc-config': 0.16.1 '@rushstack/node-core-library': 3.49.0 dev: true - /@microsoft/api-extractor/7.28.1: - resolution: {integrity: sha512-ho2GXLqausfYELSsnZb2aYxqo7xcu7hOqECXrf34pkcETx06pp5rQiUaqxdJJSpMo3LFad6PtswwnYiPRKI0OA==} + /@microsoft/api-extractor/7.28.4: + resolution: {integrity: sha512-7JeROBGYTUt4/4HPnpMscsQgLzX0OfGTQR2qOQzzh3kdkMyxmiv2mzpuhoMnwbubb1GvPcyFm+NguoqOqkCVaw==} hasBin: true dependencies: - '@microsoft/api-extractor-model': 7.20.3 + '@microsoft/api-extractor-model': 7.21.0 '@microsoft/tsdoc': 0.14.1 '@microsoft/tsdoc-config': 0.16.1 '@rushstack/node-core-library': 3.49.0 @@ -1606,15 +1606,15 @@ packages: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: true - /c12/0.2.7: - resolution: {integrity: sha512-ih1nuHbZ6Ltf8Wss96JH6YvKIW5+9+uLAA08LUQAoDrFPGSyvPvQv/QBIRE+dCBWOK4PcwH0ylRkSa9huI1Acw==} + /c12/0.2.8: + resolution: {integrity: sha512-JomSyVwGnqndRdVVW6SGnHUeHIfJFQNe/4zPFK6zLKPQm8US+hNr4kZP7xeNnzjn3jnQUsBbPdT85fm8K5Pr4A==} dependencies: defu: 6.0.0 dotenv: 16.0.1 gittar: 0.1.1 jiti: 1.14.0 mlly: 0.5.4 - pathe: 0.2.0 + pathe: 0.3.2 rc9: 1.2.2 dev: true @@ -4775,7 +4775,7 @@ packages: /mlly/0.5.4: resolution: {integrity: sha512-gFlsLWCjVwu/LM/ZfYUkmnbBoz7eyBIMUwVQYDqhd8IvtNFDeZ95uwAyxHE2Xx7tQwePQaCo4fECZ9MWFEUTgQ==} dependencies: - pathe: 0.3.1 + pathe: 0.3.2 pkg-types: 0.3.3 dev: true @@ -5020,12 +5020,8 @@ packages: engines: {node: '>=8'} dev: true - /pathe/0.2.0: - resolution: {integrity: sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==} - dev: true - - /pathe/0.3.1: - resolution: {integrity: sha512-cKMVe/pikPpreoODbjoliSk0cIT66JjEOWN30akc9WTo8kUjxFPYqmXvMBVPMSAJGJlx6v/nYzqSSHkp1cfezQ==} + /pathe/0.3.2: + resolution: {integrity: sha512-qhnmX0TOqlCvdWWTkoM83wh5J8fZ2yhbDEc9MlsnAEtEc+JCwxUKEwmd6pkY9hRe6JR1Uecbc14VcAKX2yFSTA==} dev: true /pathval/1.1.1: @@ -5060,7 +5056,7 @@ packages: dependencies: jsonc-parser: 3.0.0 mlly: 0.5.4 - pathe: 0.3.1 + pathe: 0.3.2 dev: true /postcss-selector-parser/6.0.10: @@ -5870,8 +5866,8 @@ packages: resolution: {integrity: sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==} dev: true - /tinypool/0.2.1: - resolution: {integrity: sha512-HFU5ZYVq3wBfhSaf8qdqGsneaqXm0FgJQpoUlJbVdHpRLzm77IneKAD3RjzJWZvIv0YpPB9S7LUW53f6BE6ZSg==} + /tinypool/0.2.2: + resolution: {integrity: sha512-tp4n5OARNL3v8ntdJUyo5NsDfwvUtu8isB43USjrsQxQrADDKY6UGBkmFaw/2vNmEt8S/uSm2U5FhkiK1eAFGw==} engines: {node: '>=14.0.0'} dev: true @@ -5923,15 +5919,15 @@ packages: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} dev: false - /tsdv/0.4.0_jsdom@20.0.0+sass@1.53.0: - resolution: {integrity: sha512-htIxIPPRIKZgoHw83dDgVxGZpzb2O01/KLwEdA2bL2OhchnE0qxXXgeiVB/ruRJBcdRSN3SG5gjEc86N2sApPQ==} + /tsdv/0.5.0_jsdom@20.0.0+sass@1.53.0: + resolution: {integrity: sha512-aIefTomcWiStapL01FOPlYSwBg9xllxnHc3yLu7REH2EFlA9KzJGkuL/6rdqrrk9b5+arj2u2Z4uWFJVM00Z8A==} hasBin: true dependencies: - '@microsoft/api-extractor': 7.28.1 + '@microsoft/api-extractor': 7.28.4 '@types/fs-extra': 9.0.13 '@types/lodash-es': 4.17.6 '@types/node': 18.0.0 - c12: 0.2.7 + c12: 0.2.8 cac: 6.7.12 execa: 6.1.0 find-up: 6.3.0 @@ -6299,7 +6295,7 @@ packages: debug: 4.3.4 jsdom: 20.0.0 local-pkg: 0.4.1 - tinypool: 0.2.1 + tinypool: 0.2.2 tinyspy: 0.3.3 vite: 2.9.13_sass@1.53.0 transitivePeerDependencies: diff --git a/scripts/build.mjs b/scripts/build.mjs index cd7acbe..686fc82 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -13,10 +13,13 @@ export const sveltePreprocessor = sveltePreprocess({ ], }) -const pkgName = 'decode-named-character-reference' +// do not resolve `browser` field to make CJS bundle work at SSR +// https://github.com/vitejs/vite/issues/4405 +export function getAlias(format) { + const pkgName = 'decode-named-character-reference' -export const alias = { - // do not resolve `browser` field to make it work at SSR - // https://github.com/vitejs/vite/issues/4405 - [pkgName]: resolve.sync(pkgName), + if (format === 'cjs') + return { + [pkgName]: resolve.sync(pkgName), + } }