Skip to content

Commit

Permalink
fix(types): add exports for old ts import style (#6263)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens authored May 7, 2024
1 parent 49ec522 commit 36437e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@
"core.prod.cjs",
"core.prod.mjs",
"core.d.ts",
"index.d.ts",
"jsx-dev-runtime/package.json",
"jsx-runtime/package.json",
"jsx-runtime/index.d.ts",
"jsx-runtime.d.ts",
"loader/index.cjs",
"loader/index.mjs",
Expand Down
11 changes: 10 additions & 1 deletion scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { generateQwikApiMarkdownDocs, generateQwikCityApiMarkdownDocs } from './api-docs';
import { type BuildConfig, panic, copyFile } from './util';
import { type BuildConfig, panic, copyFile, ensureDir } from './util';

/**
* Create each submodule's bundled dts file, and ensure the public API has not changed for a
Expand All @@ -17,13 +17,22 @@ export async function apiExtractorQwik(config: BuildConfig) {
join(config.distQwikPkgDir, 'core.d.ts'),
'.'
);
writeFileSync(
join(config.distQwikPkgDir, 'index.d.ts'),
`// re-export to make TS happy when not using nodenext import resolution\nexport * from './core';`
);
// Special case for jsx-runtime:
// It only re-exports JSX. Don't duplicate the types
const jsxContent = readFileSync(join(config.srcQwikDir, 'jsx-runtime.ts'), 'utf-8');
writeFileSync(
join(config.distQwikPkgDir, 'jsx-runtime.d.ts'),
`// re-export to make TS happy when not using nodenext import resolution\n${jsxContent}`
);
ensureDir(join(config.distQwikPkgDir, 'jsx-runtime'));
writeFileSync(
join(config.distQwikPkgDir, 'jsx-runtime', 'index.d.ts'),
`// re-export to make TS happy when not using nodenext import resolution\nexport * from '../jsx-runtime';`
);
createTypesApi(
config,
join(config.srcQwikDir, 'optimizer'),
Expand Down

0 comments on commit 36437e8

Please sign in to comment.