diff --git a/internal/bundler/linker.go b/internal/bundler/linker.go index babbcea7cfa..8e8c3ce2ed5 100644 --- a/internal/bundler/linker.go +++ b/internal/bundler/linker.go @@ -3782,7 +3782,12 @@ func (repr *chunkReprJS) generate(c *linkerContext, chunk *chunkInfo) func(gener if !isFirstMeta { jMeta.AddString("\n ") } - jMeta.AddString("],\n \"inputs\": {") + if chunk.isEntryPoint { + entryPoint := c.files[chunk.sourceIndex].source.PrettyPath + jMeta.AddString(fmt.Sprintf("],\n \"entryPoint\": %s,\n \"inputs\": {", js_printer.QuoteForJSON(entryPoint, c.options.ASCIIOnly))) + } else { + jMeta.AddString("],\n \"inputs\": {") + } } // Concatenate the generated JavaScript chunks together diff --git a/lib/types.ts b/lib/types.ts index 40e1223dc39..cc148dc241b 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -277,6 +277,7 @@ export interface Metadata { kind: MetadataImportKind }[] exports: string[] + entryPoint?: string } } } diff --git a/scripts/js-api-tests.js b/scripts/js-api-tests.js index 6c8a7c0c8c5..617c727cd4d 100644 --- a/scripts/js-api-tests.js +++ b/scripts/js-api-tests.js @@ -824,6 +824,7 @@ body { assert.deepStrictEqual(json.inputs[makePath(entry)].imports, []) assert.deepStrictEqual(json.outputs[makePath(outfile)].imports, []) assert.deepStrictEqual(json.outputs[makePath(outfile)].exports, []) + assert.deepStrictEqual(json.outputs[makePath(outfile)].entryPoint, makePath(entry)) }, async metafileCJSInFormatESM({ esbuild, testDir }) { @@ -947,6 +948,7 @@ body { assert.deepStrictEqual(json.inputs[makePath(nested3)].imports, []) assert.deepStrictEqual(json.outputs[makePath(outfile)].imports, []) assert.deepStrictEqual(json.outputs[makePath(outfile)].exports, ['nested1', 'nested2', 'topLevel']) + assert.deepStrictEqual(json.outputs[makePath(outfile)].entryPoint, makePath(entry)) }, async metafileCSS({ esbuild, testDir }) {