quarkiverse / quarkus-web-bundler

Create full-stack web apps quickly and easily with this Quarkus extension. It offers zero-configuration bundling for your web app scripts (JS, JSX, TS, TSX), dependencies (jQuery, React, htmx, etc.), and styles (CSS, SCSS, SASS).
Apache License 2.0
16 stars 9 forks source link

Supporting web-bundler usage in other extensions #193

Closed FroMage closed 2 weeks ago

FroMage commented 2 months ago

The Renarde Backoffice extension uses Bootstrap, from webjars. I'd prefer for it to use web-bundler, but for that I need to be able to make sure it doesn't pollute end users who might want to not have Bootstrap end up in their bundles.

Perhaps we need a build item for my extension to declare its dependencies on mvnpm modules and get its own "private" bundle that would not be visible from the end user's bundle?

FroMage commented 2 months ago

See https://github.com/quarkiverse/quarkus-renarde/issues/208

phillip-kruger commented 2 months ago

What about adding it in your deployment module and do the bundling there? That should not influence the user

ia3andy commented 2 months ago

@phillip-kruger even deployment mvnpm deps are leaking into the user project AFAIK

phillip-kruger commented 2 months ago

No that should not ( except in Dev mode)

ia3andy commented 2 months ago

I went for this solution: https://github.com/quarkiverse/quarkus-renarde/pull/210

Simpler to put in place and no leaking for sure.

ia3andy commented 2 months ago

No that should not ( except in Dev mode)

I think they are even in normal as web-bundler is also getting compile scope deps

phillip-kruger commented 2 months ago

In the final deployable unit? That will defeat the whole purpose of having two modules and should definitely not happen. @aloubyansky ?

FroMage commented 2 months ago

OK, so, perhaps the solution is to let me do this in my extension:

@BuildStep
WebBundlerExtensionBundle requireBootstrap() {
 return WebBundlerExtensionBundle.bundleFor("renarde-backoffice" /* name of bundle */)
  .dependency("org.webjars", "bootstrap", "5.2.3")
  .dependency("org.webjars.npm", "bootstrap-icons", "1.10.3")
  .build();
}

And without declaring any dependency that leak into the user's CP, the Web Bundler will make a bundle for me, named renarde-backoffice, made out of these dependencies that I defined. This won't leak into the user's bundles, and the user's bundles won't leak into my extension's bundle.

WDYT?

phillip-kruger commented 2 months ago

Sounds good to me.

ia3andy commented 2 months ago

OK, so, perhaps the solution is to let me do this in my extension:

@BuildStep
WebBundlerExtensionBundle requireBootstrap() {
 return WebBundlerExtensionBundle.bundleFor("renarde-backoffice" /* name of bundle */)
  .dependency("org.webjars", "bootstrap", "5.2.3")
  .dependency("org.webjars.npm", "bootstrap-icons", "1.10.3")
  .build();
}

And without declaring any dependency that leak into the user's CP, the Web Bundler will make a bundle for me, named renarde-backoffice, made out of these dependencies that I defined. This won't leak into the user's bundles, and the user's bundles won't leak into my extension's bundle.

WDYT?

we don't have a maven resolver in the buildsteps AFAIK

aloubyansky commented 2 months ago

OK, so, perhaps the solution is to let me do this in my extension:

@BuildStep
WebBundlerExtensionBundle requireBootstrap() {
 return WebBundlerExtensionBundle.bundleFor("renarde-backoffice" /* name of bundle */)
  .dependency("org.webjars", "bootstrap", "5.2.3")
  .dependency("org.webjars.npm", "bootstrap-icons", "1.10.3")
  .build();
}

And without declaring any dependency that leak into the user's CP, the Web Bundler will make a bundle for me, named renarde-backoffice, made out of these dependencies that I defined. This won't leak into the user's bundles, and the user's bundles won't leak into my extension's bundle. WDYT?

we don't have a maven resolver in the buildsteps AFAIK

We don't and we should avoid doing that. In case the dependencies for your extension do not change depending on an app then we could imagine declaring a "named dependency set" that would be pre-resolved and exposed to you during the build somehow.

aloubyansky commented 2 months ago

Basically, you would define this list of dependencies in extension metadata and you would give it a name that you could use to obtain it from some bootstrap API (possibly ApplicationModel.getNamedDependencyModel(name)` or something).

FroMage commented 2 months ago

In case the dependencies for your extension do not change depending on an app

They don't change depending on the app, indeed.

ia3andy commented 2 weeks ago

This is done