Skip to content

Commit

Permalink
fix: revert regression in #1298
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jan 8, 2025
1 parent a6fe062 commit 445ffc9
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 66 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@babel/core": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@babel/types": "^7.26.3",
"@microsoft/api-extractor": "7.49.0",
"@microsoft/api-extractor": "7.48.1",
"@microsoft/tsdoc-config": "0.17.1",
"@optimize-lodash/rollup-plugin": "5.0.0",
"@rollup/plugin-alias": "^5.1.1",
Expand Down
2 changes: 1 addition & 1 deletion playground/react-18/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react-compiler-runtime": "beta"
},
"devDependencies": {
"@types/react": "^18.3.18",
"@types/react": "^19.0.4",
"babel-plugin-react-compiler": "beta",
"react": "^18.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion playground/react-19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build": "pkg build --strict --check --clean"
},
"devDependencies": {
"@types/react": "^19.0.3",
"@types/react": "^19.0.4",
"babel-plugin-react-compiler": "beta",
"react": "^19.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion playground/runtime-next-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "next dev --turbo"
},
"devDependencies": {
"@types/react": "^19.0.3",
"@types/react": "^19.0.4",
"dummy-module": "workspace:*",
"next": "^15.1.4",
"react": "^19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion playground/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@types/react": "^19.0.3",
"@types/react": "^19.0.4",
"babel-plugin-react-compiler": "beta",
"babel-plugin-styled-components": "^2.1.4",
"react": "^19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion playground/use-client-directive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean": "rimraf dist"
},
"devDependencies": {
"@types/react": "^19.0.3",
"@types/react": "^19.0.4",
"react": "^19.0.0"
},
"peerDependencies": {
Expand Down
57 changes: 22 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 33 additions & 12 deletions src/node/tasks/dts/createApiExtractorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,45 @@ export function createApiExtractorConfig(options: {
tsconfigPath,
} = options

// When the module is 'preserve' it's necessary to override the tsconfig file as api-extractor doesn't handle it out of the box
const workaroundModulePreserve = tsconfig.options.module === ts.ModuleKind.Preserve
// If `paths` are used for self-referencing imports (e.g. the module is named `sanity`, and the `sanity/structure` export is also importing from `sanity/router`),
const workaroundPaths = !!tsconfig.options.paths

const overrideTsconfig = {
extends: tsconfigPath,
compilerOptions: {},
}

if (workaroundModulePreserve) {
Object.assign(overrideTsconfig.compilerOptions, {
// Set the equivalent options to `module: 'Preserve'`
// https://github.com/microsoft/TypeScript/pull/56785/files?file-filters%5B%5D=.js&file-filters%5B%5D=.json&file-filters%5B%5D=.symbols&file-filters%5B%5D=.ts&file-filters%5B%5D=.types&show-viewed-files=true#diff-31d3c12bafea26bc9e8c8a77920c41af0c593206442add70c45a06c063767445
module: 'ESNext',
moduleResolution: 'Bundler',
esModuleInterop: true,
resolveJsonModule: true,
})
}

if (workaroundPaths) {
Object.assign(overrideTsconfig.compilerOptions, {
// An empty object replaces whatever is in the original tsconfig file
paths: {},
})
}

return {
apiReport: {
enabled: false,
reportFileName: '<unscopedPackageName>.api.md',
},
bundledPackages,
// If `paths` are used for self-referencing imports (e.g. the module is named `sanity`, and the `sanity/structure` export is also importing from `sanity/router`),
compiler: tsconfig.options.paths
? {
overrideTsconfig: {
extends: tsconfigPath,
compilerOptions: {
// An empty object replaces whatever is in the original tsconfig file
paths: {},
},
},
}
: {tsconfigFilePath: tsconfigPath},

compiler:
workaroundModulePreserve || workaroundPaths
? {overrideTsconfig}
: {tsconfigFilePath: tsconfigPath},

docModel: {
enabled: false,
Expand Down
15 changes: 2 additions & 13 deletions test/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,10 @@ export {
`;

exports[`should build \`multi-export\` package 6`] = `
"/** @public */
export declare function plugin(): Plugin_2
"import {Plugin as Plugin_2} from 'multi-export'
/** @public */
declare interface Plugin_2 {
name: string
options?: PluginOptions
}
declare interface PluginOptions {
/**
* @defaultValue true
*/
enabled?: boolean
}
export declare function plugin(): Plugin_2
export {}
"
Expand Down

0 comments on commit 445ffc9

Please sign in to comment.