Skip to content

Commit

Permalink
include json (other than package.json)
Browse files Browse the repository at this point in the history
Fix: #73
  • Loading branch information
isaacs committed Jun 25, 2024
1 parent ef27862 commit 64e138e
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 43 deletions.
7 changes: 5 additions & 2 deletions .tshy/esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/package.json"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
Expand Down
31 changes: 24 additions & 7 deletions src/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
exclude = [],
} = config

const relativeExclude = exclude.map(e => `../${e}`)
const relativeExclude = exclude.map(e => `../${e.replace(/^\.\//, '')}`)

const recommended: Record<string, any> = {
compilerOptions: {
Expand Down Expand Up @@ -61,7 +61,11 @@ const build = (): Record<string, any> => ({
})

const commonjs = (dialect: string): Record<string, any> => {
const exclude = [...relativeExclude, '../src/**/*.mts']
const exclude = [
...relativeExclude,
'../src/**/*.mts',
'../src/package.json',
]
for (const [d, pf] of polyfills) {
if (d === dialect) continue
for (const f of pf.map.keys()) {
Expand All @@ -70,7 +74,12 @@ const commonjs = (dialect: string): Record<string, any> => {
}
return {
extends: './build.json',
include: ['../src/**/*.ts', '../src/**/*.cts', '../src/**/*.tsx'],
include: [
'../src/**/*.ts',
'../src/**/*.cts',
'../src/**/*.tsx',
'../src/**/*.json',
],
exclude,
compilerOptions: {
outDir:
Expand All @@ -81,17 +90,25 @@ const commonjs = (dialect: string): Record<string, any> => {
}

const esm = (dialect: string): Record<string, any> => {
const exclude: string[] = [...relativeExclude]
const exclude: string[] = [
...relativeExclude,
'../src/package.json',
]
for (const [d, pf] of polyfills) {
if (d === dialect) continue
for (const f of pf.map.keys()) {
exclude.push(`../${f}`)
exclude.push(`../${f.replace(/^\.\//, '')}`)
}
}
return {
extends: './build.json',
include: ['../src/**/*.ts', '../src/**/*.mts', '../src/**/*.tsx'],
exclude: exclude,
include: [
'../src/**/*.ts',
'../src/**/*.mts',
'../src/**/*.tsx',
'../src/**/*.json',
],
exclude,
compilerOptions: {
outDir: '../.tshy-build/' + dialect,
},
Expand Down
48 changes: 34 additions & 14 deletions tap-snapshots/test/tsconfig.ts.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ Object {
},
"exclude": Array [
"../src/**/*.mts",
"../src/package.json",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -41,13 +43,15 @@ Object {
"outDir": "../.tshy-build/deno",
},
"exclude": Array [
".././src/index-cjs.cts",
"../src/package.json",
"../src/index-cjs.cts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -58,14 +62,16 @@ Object {
"outDir": "../.tshy-build/esm",
},
"exclude": Array [
".././src/index-cjs.cts",
".././src/index-deno.mts",
"../src/package.json",
"../src/index-cjs.cts",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -77,6 +83,7 @@ Object {
},
"exclude": Array [
"../src/**/*.mts",
"../src/package.json",
"../src/index-cjs.cts",
"../src/index-deno.mts",
],
Expand All @@ -85,6 +92,7 @@ Object {
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand Down Expand Up @@ -127,15 +135,17 @@ Object {
"outDir": "../.tshy-build/commonjs",
},
"exclude": Array [
".././src/**/*.test.ts",
"../src/**/*.test.ts",
"../src/**/*.mts",
"../src/package.json",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -146,15 +156,17 @@ Object {
"outDir": "../.tshy-build/commonjs",
},
"exclude": Array [
".././src/**/*.test.ts",
"../src/**/*.test.ts",
"../src/**/*.mts",
"../src/package.json",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -165,14 +177,16 @@ Object {
"outDir": "../.tshy-build/deno",
},
"exclude": Array [
".././src/**/*.test.ts",
".././src/index-cjs.cts",
"../src/**/*.test.ts",
"../src/package.json",
"../src/index-cjs.cts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -183,15 +197,17 @@ Object {
"outDir": "../.tshy-build/esm",
},
"exclude": Array [
".././src/**/*.test.ts",
".././src/index-cjs.cts",
".././src/index-deno.mts",
"../src/**/*.test.ts",
"../src/package.json",
"../src/index-cjs.cts",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -202,15 +218,17 @@ Object {
"outDir": "../.tshy-build/esm",
},
"exclude": Array [
".././src/**/*.test.ts",
".././src/index-cjs.cts",
".././src/index-deno.mts",
"../src/**/*.test.ts",
"../src/package.json",
"../src/index-cjs.cts",
"../src/index-deno.mts",
],
"extends": "./build.json",
"include": Array [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand All @@ -221,8 +239,9 @@ Object {
"outDir": "../.tshy-build/webpack",
},
"exclude": Array [
".././src/**/*.test.ts",
"../src/**/*.test.ts",
"../src/**/*.mts",
"../src/package.json",
"../src/index-cjs.cts",
"../src/index-deno.mts",
],
Expand All @@ -231,6 +250,7 @@ Object {
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json",
],
}
`
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/basic-custom-project/.tshy/commonjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/**/*.mts"
"../src/**/*.mts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/basic-custom-project/.tshy/esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/package.json"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/basic-imports-only-deps/.tshy/commonjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/**/*.mts"
"../src/**/*.mts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/basic-imports-only-deps/.tshy/esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/package.json"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/basic/.tshy/commonjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/**/*.mts"
"../src/**/*.mts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/basic/.tshy/esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/package.json"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/imports-with-star/.tshy/commonjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/**/*.mts"
"../src/**/*.mts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/imports-with-star/.tshy/esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../src/package.json"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
Expand Down
Loading

0 comments on commit 64e138e

Please sign in to comment.