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

Allow LSPAssetsPlugin to Load Assets from Module #98

Open
KetanReddy opened this issue Apr 15, 2024 · 0 comments
Open

Allow LSPAssetsPlugin to Load Assets from Module #98

KetanReddy opened this issue Apr 15, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@KetanReddy
Copy link
Member

KetanReddy commented Apr 15, 2024

Problem

Currently, the CLI's LSPAssetsPlugin plugin only allows users to specify a file path to load XLRs into the LSP. This requires some unfriendly initialization of the plugin when passing XLR enabled packages as you would need to do something like the below to initialize it:

new LSPAssetsPlugin({
        path: path.join(require.resolve('@player-ui/types'), '..')
      })

Given that the entrypoint for each module can be different, the added effort of finding how many levels to go up from the entrypoint to get to the xlr folder in the module may require some trial and error.

Proposed Solution

If we embrace subpath exports (which are supported back through node 14) to allow the manifest.js file in the generated XLR folder to be accessed via a subpath, the package author can easily expose the XLR location and the integration author can access it in a standard way without having to know how the original package is setup. Example:

In the XLR enabled library's package.json

...
"exports": {
    "./xlr": "./dist/xlr/manifest.js"
  },
...

In the CLI Preset of the integrating application

new LSPAssetsPlugin({
        path: require.resolve('@player-ui/types/xlr')
      })

Work to Do

  • Update Player's Bazel rules to generate a subpath export for XLR enabled packages
  • Update LSPAssetsPlugin to allow loading XLRs via Module or Make a new plugin for specifically loading XLRs via module
@KetanReddy KetanReddy added enhancement New feature or request good first issue Good for newcomers labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant