Skip to content

Commit

Permalink
entryPoint information in metafile (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
remorses authored Feb 23, 2021
1 parent 2b38fb8 commit b6f8b82
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/bundler/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export interface Metadata {
kind: MetadataImportKind
}[]
exports: string[]
entryPoint?: string
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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 }) {
Expand Down

0 comments on commit b6f8b82

Please sign in to comment.