-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
how do i declare global mappings ? #12
Comments
Hi @lgersman ! Since v0.0.18, nanobundle has "standalone mode", which tries to inline all dependencies. In standalone mode, you can specify explicitly which dependency will not be inlined. https://github.com/cometkim/nanobundle/tree/v0.0.18#embedding-dependencies I'm not sure this option and microbundle's option you mentioned is met your requirement. Can you provide some esbuild or rollup config you use for it? |
Hello @cometkim, the reason for my question is that i would like to use your nanobundle to bundle Wordpress Gutenberg blocks. These blocks consists of Javascript running in the browser inside the Gutenberg Editor. The Gutenberg Editor provides React and many of the @wordpress/* packages via global variable That means that these packages dont need to be bundled but transpiled to access the import using global variables (like in Rollup you would declare that like this :
The transpilation is also possible using esbuild (see here : https://github.com/lgersman/ix-article-esbuild-2021/blob/develop/bin/esbuild-bundle.mjs#L64) |
Ok, I understand your requirement. I'm trying to keep the config of nanobundle as simple as possible. I could also explore a good place for additional config per dependency in
export const {
Button,
} = window.wp.components;
{
"imports": {
"@wordpress/components": "./vendor/wp-components.js"
}
} |
Good morning, I understand your reasons (simplicity !) but some packages may expose dozens of exports ... which will result in a huge amount of import map code. Don't you think there is a better way to expose globals ? |
Of course, simplicity is important, but there is another big problem here. Adding personal opinions without esbuild config already existing or well-known standards is against the goal of the nanobundle. Maybe it makes sense to provide an escape hatch that allows custom plugins for other cases. |
Sounds good.
Hyeseong Kim ***@***.***> schrieb am Do., 23. Dez. 2021,
15:49:
… Of course, simplicity is important, but there is another big problem here.
Adding personal opinions without esbuild config already existing or
well-known standards is against the goal of the nanobundle.
Maybe it makes sense to provide an escape hatch that allows custom plugins
for other cases.
—
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAT5NY5YXC4MTPCV2ETJR3USMZGNANCNFSM5KG2R7ZQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi,
I like to prevent inlining packages imported like "react" and "@wordpress/components" BUT reference them from global variables.
An example:
import { Button } from ''@wordpress/components';
should be transpiled toconst { Button } = windows.wp.components;
microbundle allows "something like that" to declare globals as commandline option and also a way to do control at least inlining via convention : https://github.com/developit/microbundle/wiki/How-Microbundle-decides-which-dependencies-to-bundle
How can I do this with nanobundle ?
Kind regards,
Lars
The text was updated successfully, but these errors were encountered: