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

Make any npm module a plugin via a proxy plugin config #2382

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

BenSurgisonGDS
Copy link
Contributor

@BenSurgisonGDS BenSurgisonGDS commented Nov 23, 2023

I've had a several requests from people to allow npm modules to load their script, sass files and assets as they would a plugin.

A designer was trying to use the npm module browser-fs-access but was having difficulty loading the scripts from node_modules. This PR adds support for a new json file /app/plugin-proxy.json that contains a proxy plugin config for the module that treats the npm module as a plugin which solved his issue neatly:

{
    "browser-fs-access": {
        "scripts": {
            "type": "module",
            "path": "/dist/index.modern.js"
        }
    }
}

I'm suggesting this be introduced as it will not affect anyone who has not created the /app/plugin-proxy.json file with a view to documenting the use of this at a later date. For now it gets over the issue of wanting something to be a plugin without hard coding it for everyone.

@BenSurgisonGDS BenSurgisonGDS marked this pull request as ready for review November 24, 2023 16:14
@BenSurgisonGDS BenSurgisonGDS changed the title Experimental proxy Introduce the ability to make any npm module a plugin via a proxy plugin config Nov 24, 2023
@BenSurgisonGDS BenSurgisonGDS force-pushed the experimental-proxy branch 2 times, most recently from 1059f13 to 2cdec15 Compare November 24, 2023 16:31
@BenSurgisonGDS BenSurgisonGDS changed the title Introduce the ability to make any npm module a plugin via a proxy plugin config Make any npm module a plugin via a proxy plugin config Nov 24, 2023
@gazjoy
Copy link

gazjoy commented Nov 27, 2023

Hello folks, just for some additional context it was me who was trying to install the JS module.

My use case is around testing different ways in which users expect to get a copy of their application as mentioned in this issue: alphagov/govuk-design-system-backlog#234

We're looking at how we might show users a "save as" dialog so they are at less risk of losing the mental model of where a download goes.

@BenSurgisonGDS BenSurgisonGDS merged commit 667abeb into main Nov 27, 2023
30 checks passed
@BenSurgisonGDS BenSurgisonGDS deleted the experimental-proxy branch November 27, 2023 16:33
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.

3 participants