-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from DataDog/yoann/new-internal-plugins
[refactor] Better integrate new internal plugins
- Loading branch information
Showing
33 changed files
with
836 additions
and
550 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,125 @@ | ||
# Factory | ||
# Factory <!-- #omit in toc --> | ||
|
||
This is used to aggregate all the plugins and expose them to the bundler. | ||
|
||
We use [unplugin](https://unplugin.unjs.io/) to support many different bundlers. | ||
> [!NOTE] | ||
> We use [unplugin](https://unplugin.unjs.io/) to support many different bundlers. | ||
<!-- This is auto generated with yarn cli integrity --> | ||
|
||
<!-- #toc --> | ||
- [Internal Plugins](#internal-plugins) | ||
- [Build Report](#build-report) | ||
- [Bundler Report](#bundler-report) | ||
- [Git](#git) | ||
- [Injection](#injection) | ||
- [Global Context](#global-context) | ||
<!-- #toc --> | ||
|
||
## Internal Plugins | ||
|
||
These are the plugins that are used internally by the factory. | ||
Most of the time they will interact via the global context. | ||
|
||
<!-- #internal-plugins-list --> | ||
### Build Report | ||
|
||
> This will populate `context.build` with a bunch of data coming from the build. | ||
<kbd>[📝 Full documentation ➡️](/packages/plugins/build-report#readme)</kbd> | ||
|
||
### Bundler Report | ||
|
||
> A very basic report on the currently used bundler.<br/> | ||
> It is useful to unify some configurations. | ||
<kbd>[📝 Full documentation ➡️](/packages/plugins/bundler-report#readme)</kbd> | ||
|
||
### Git | ||
|
||
> Adds repository data to the global context from the `buildStart` hook. | ||
<kbd>[📝 Full documentation ➡️](/packages/plugins/git#readme)</kbd> | ||
|
||
### Injection | ||
|
||
> This is used to prepend some code to the produced bundle.<br/> | ||
> Particularly useful if you want to share some global context, or to automatically inject some SDK. | ||
<kbd>[📝 Full documentation ➡️](/packages/plugins/injection#readme)</kbd> | ||
<!-- #internal-plugins-list --> | ||
|
||
## Global Context | ||
|
||
A global, shared context within the build plugins ecosystem.<br/> | ||
It is passed to your plugin's initialization, and **is mutated during the build process**. | ||
|
||
```typescript | ||
type GlobalContext = { | ||
// Mirror of the user's config. | ||
auth?: { | ||
apiKey?: string; | ||
}; | ||
// More details on the currently running bundler. | ||
bundler: { | ||
name: string; | ||
fullName: string; // Including its variant. | ||
outDir: string; // Output directory | ||
// Added in `buildStart`. | ||
rawConfig?: any; | ||
variant: string; // Major version of the bundler (webpack 4, webpack 5), empty string otherwise. | ||
}; | ||
// Added in `writeBundle`. | ||
build: { | ||
errors: string[]; | ||
warnings: string[]; | ||
// The list of entries used in the build. | ||
entries ? : { | ||
filepath: string; | ||
inputs: Input[], | ||
name: string; | ||
outputs: Output[] | ||
size: number; | ||
type: string, | ||
} []; | ||
// The list of inputs used in the build. | ||
inputs ? : { | ||
filepath: string; | ||
dependencies: Input[]; | ||
dependents: Input[] | ||
name: string; | ||
size: number; | ||
type: string, | ||
} []; | ||
// The list of outputs generated by the build. | ||
outputs ? : { | ||
filepath: string; | ||
name: string; | ||
size: number; | ||
type: string, | ||
// Sourcemaps will use Outputs as their Inputs. | ||
inputs: (Input | Output)[] | ||
} []; | ||
start?: number; | ||
end?: number; | ||
duration?: number; | ||
writeDuration?: number; | ||
}; | ||
cwd: string; | ||
// Added in `buildStart`. | ||
git?: { | ||
hash: string; | ||
remote: string; | ||
trackedFilesMatcher: [TrackedFilesMatcher](/packages/plugins/git/trackedFilesMatcher.ts); | ||
}; | ||
inject: (item: { type: 'file' | 'code'; value: string; fallback?: @self }) => void; | ||
start: number; | ||
version: string; | ||
} | ||
``` | ||
> [!NOTE] | ||
> Some parts of the context are only available after certain hooks: | ||
> - `context.bundler.rawConfig` is added in the `buildStart` hook. | ||
> - `context.build.*` is populated in the `writeBundle` hook. | ||
> - `context.git.*` is populated in the `buildStart` hook. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.