Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Re-organise project files. #107

Merged
merged 9 commits into from
Nov 14, 2024
Merged

Conversation

yoannmoinet
Copy link
Member

@yoannmoinet yoannmoinet commented Oct 30, 2024

What and why?

Project files are a bit mis-organised.
Especially in /packages/core/src/plugins/**, these should all move as full-fledged workspaces in /packages/plugins/*.

Also, having the published bundler plugins /packages/{bundler}-plugin at the root is noisy. They should be moved into their own directory /packages/published/{bundler}-plugin.

How?

  • Move /packages/core/src/plugins/* => /packages/plugins/*.
  • Move /packages/*-plugin => /packages/published/*-plugin.
  • Move /packages/tests/{fixtures,jest,helpers} => /packages/tests/_jest/*.
  • Update paths, readmes, tests and dependencies.
  • Renamed @dd/rum-plugins => @dd/rum-plugin for consistency.
  • Renamed @dd/telemetry-plugins => @dd/telemetry-plugin for consistency.
  • Created @dd/internal-context-plugin to handle the global context.

New, simpler diagram:

---
title: Datadog Build Plugins Design
---
stateDiagram-v2
    published: Published Packages
    productPlugins: Product Plugins
    productPlugin: @dd/{product}-plugin
    productPlugin2: [...]
    esbuildplugin: @datadog/esbuild-plugin
    viteplugin: @datadog/vite-plugin
    rollupplugin: @datadog/rollup-plugin
    webpackplugin: @datadog/webpack-plugin
    tools: @dd/tools
    factory: @dd/factory
    core: @dd/core
    types: Shared Types
    sharedHelpers: Shared Helpers
    sharedConstants: Shared Constants
    helpers: Aggregated Helpers
    atypes: Aggregated Types
    aplugins: Aggregated List of Plugins
    contextCreation: Creation of the Global Context
    cli: Internal CLIs
    internalPlugins: Internal Plugins
    buildReportPlugin: @dd/internal-build-report-plugin
    bundlerReportPlugin: @dd/internal-bundler-report-plugin
    contextPlugin: @dd/internal-context-plugin
    injectionPlugin: @dd/internal-injection-plugin
    gitPlugin: @dd/internal-git-plugin

    state internalPlugins {
        buildReportPlugin
        bundlerReportPlugin
        contextPlugin
        gitPlugin
        injectionPlugin
    }

    state core {
        getLogger()
        sharedHelpers
        sharedConstants
        types
    }

    state published {
        esbuildplugin
        viteplugin
        rollupplugin
        webpackplugin
    }

    state productPlugins {
        productPlugin
        productPlugin2
    }

    state factory {
        contextCreation
        helpers
        atypes
        aplugins
    }

    state tools {
        cli
    }

    internalPlugins --> factory
    productPlugins --> factory: CONFIG_KEY<br/>helpers<br/>types<br/>getPlugins()
    core --> tools
    core --> factory
    core --> internalPlugins
    core --> productPlugins
    factory --> productPlugins: Global Context
    factory --> published: Unplugin Factory
    published --> NPM: types<br/>helpers<br/>datadogBundlerPlugin
Loading

Compared to previous one:

---
title: Datadog Build Plugins Design
---
stateDiagram-v2
    published: Published Packages
    plugins: Custom Plugins
    customplugin1: @dd/*-plugins
    customplugin2: @dd/*-plugins
    customplugin3: [...]
    esbuildplugin: @datadog/esbuild-plugin
    viteplugin: @datadog/vite-plugin
    rollupplugin: @datadog/rollup-plugin
    webpackplugin: @datadog/webpack-plugin
    tools: @dd/tools
    factory: @dd/factory
    core: @dd/core
    types: Shared Types
    helpers: Aggregated Helpers
    atypes: Aggregated Types
    aplugins: Aggregated List of Plugins
    cli: Internal CLIs
    internalPlugins: Internal Plugins
    buildReportPlugin: Build Report Plugin
    bundlerReportPlugin: Bundler Report Plugin
    injectionPlugin: Injection Plugin
    gitPlugin: Git Plugin

    state internalPlugins {
        buildReportPlugin
        bundlerReportPlugin
        gitPlugin
        injectionPlugin
    }

    state core {
        getLogger()
        types
        internalPlugins
    }

    state published {
        esbuildplugin
        viteplugin
        rollupplugin
        webpackplugin
    }

    state plugins {
        customplugin1
        customplugin2
        customplugin3
    }

    state factory {
        helpers
        atypes
        aplugins
    }

    state tools {
        cli
    }

    plugins --> factory: CONFIG_KEY<br/>helpers<br/>types<br/>getPlugins()
    core --> tools: types
    core --> factory: Internal Plugins<br/>types
    core --> plugins: getLogger()<br/>types
    factory --> plugins: Global Context
    factory --> published: Unplugin Factory
    published --> NPM: types<br/>helpers<br/>datadogBundlerPlugin
Loading

@@ -15,9 +15,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
Copy link
Collaborator

Choose a reason for hiding this comment

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

👌

@@ -13,12 +13,17 @@
},
"exports": {
".": "./src/index.ts",
"./*": "./src/*"
"./*": "./src/*.ts"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice change!

@@ -37,4 +37,4 @@ export default {

## Configuration

Check the main [README](../../README.md#configuration) for the common configuration options.
Check the main [README](/README.md#configuration) for the common configuration options.
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL!

Copy link
Collaborator

@Ayc0 Ayc0 left a comment

Choose a reason for hiding this comment

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

Nice!

@yoannmoinet yoannmoinet marked this pull request as ready for review November 12, 2024 10:48
@yoannmoinet yoannmoinet requested a review from a team as a code owner November 12, 2024 10:48
@yoannmoinet yoannmoinet requested review from sarenji and removed request for a team November 12, 2024 10:48
@yoannmoinet yoannmoinet removed the request for review from sarenji November 12, 2024 13:39
Base automatically changed from yoann/change-bundling to master November 14, 2024 16:09
@yoannmoinet yoannmoinet merged commit 36acb24 into master Nov 14, 2024
5 checks passed
@yoannmoinet yoannmoinet deleted the yoann/re-org-files branch November 14, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants