Skip to content

Commit 30d3a3c

Browse files
chore(build): port d.ts bundling for mock-doc from rollup to esbuild (#5624)
In #5012 when we put together a script to build `mock-doc/` with Esbuild we refactored a custom, hand-built `.d.ts` bundler that was used in the Rollup build to instead use `dts-bundle-generator`, a library that we depend on elsewhere. Although in theory a better option for avoiding NIH syndrome the output is just too different, so we want to switch to using the old rollup approach in our new, Esbuild-based build script for `mock-doc/`. To accomplish this we can just export the existing function from the Rollup script and then call it in the Esbuild script. STENCIL-1246
1 parent 89a5e40 commit 30d3a3c

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

scripts/bundles/mock-doc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ return exports;
6868
})({});
6969
`.trim();
7070

71-
async function bundleMockDocDts(inputDir: string, outputDir: string) {
71+
export async function bundleMockDocDts(inputDir: string, outputDir: string) {
7272
// only reason we can do this is because we already know the shape
7373
// of mock-doc's dts files and how we want them to come together
7474
const srcDtsFiles = (await fs.readdir(inputDir)).filter((f) => {

scripts/esbuild/mock-doc.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { BuildOptions as ESBuildOptions } from 'esbuild';
22
import fs from 'fs-extra';
33
import { join } from 'path';
44

5+
import { bundleMockDocDts } from '../bundles/mock-doc';
56
import { bundleParse5 } from '../bundles/plugins/parse5-plugin';
67
import { getBanner } from '../utils/banner';
7-
import { bundleDts } from '../utils/bundle-dts';
88
import { BuildOptions, createReplaceData } from '../utils/options';
99
import { writePkgJson } from '../utils/write-pkg-json';
1010
import { getBaseEsbuildOptions, getEsbuildAliases, runBuilds } from './util';
@@ -23,8 +23,7 @@ export async function buildMockDoc(opts: BuildOptions) {
2323
// clear out rollup stuff and ensure directory exists
2424
await fs.emptyDir(outputDir);
2525

26-
// bundle d.ts
27-
await bundleMockDocDts(opts, inputDir, outputDir);
26+
await bundleMockDocDts(inputDir, outputDir);
2827

2928
writePkgJson(opts, outputDir, {
3029
name: '@stencil/core/mock-doc',
@@ -71,21 +70,3 @@ export async function buildMockDoc(opts: BuildOptions) {
7170

7271
return runBuilds([esmOptions, cjsOptions], opts);
7372
}
74-
75-
async function bundleMockDocDts(opts: BuildOptions, inputDir: string, outputDir: string) {
76-
const bundled = await bundleDts(
77-
opts,
78-
join(inputDir, 'index.ts'),
79-
{
80-
// we want to suppress the `dts-bundle-generator` banner here because we do
81-
// our own later on
82-
noBanner: true,
83-
// we also don't want the types which are inlined into our bundled file to
84-
// be re-exported, which will change the 'surface' of the module
85-
exportReferencedTypes: false,
86-
},
87-
false,
88-
);
89-
90-
await fs.writeFile(join(outputDir, 'index.d.ts'), bundled);
91-
}

0 commit comments

Comments
 (0)