Skip to content

Commit

Permalink
refactor(plugin-api): expose entryPoint and more info in chunkInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 14, 2023
1 parent 49cde79 commit 9639352
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugin.ts
Expand Up @@ -16,6 +16,9 @@ export type ChunkInfo = {
* Sets the file mode
*/
mode?: number
entryPoint?: string
exports?: string[]
imports?: Metafile['outputs'][string]['imports']
}

export type AssetInfo = {
Expand Down Expand Up @@ -119,13 +122,18 @@ export class PluginContainer {
}) {
const files: Array<ChunkInfo | AssetInfo> = outputFiles
.filter((file) => !file.path.endsWith('.map'))
.map((file) => {
.map((file): ChunkInfo | AssetInfo => {
if (isJS(file.path) || isCSS(file.path)) {
const relativePath = path.relative(process.cwd(), file.path)
const meta = metafile?.outputs[relativePath]
return {
type: 'chunk',
path: file.path,
code: file.text,
map: outputFiles.find((f) => f.path === `${file.path}.map`)?.text,
entryPoint: meta?.entryPoint,
exports: meta?.exports,
imports: meta?.imports,
}
} else {
return { type: 'asset', path: file.path, contents: file.contents }
Expand Down

1 comment on commit 9639352

@vercel
Copy link

@vercel vercel bot commented on 9639352 Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.