Hello,
I trying to generate an UMD bundle including all the dependencies necessary. This is the code:
https://github.com/microlinkhq/microlinkjs/blob/master/packages/microlinkjs/src/index.js
I'm running the following command:
❯ NODE_ENV=production npx microbundle build --target browser --entry lib/index.js --format es,cjs --inline all
Build output to lib:
1.54 kB: index.js
1.54 kB: index.m.js
But the filesize is too small, because it doesn't include all the code dependencies.
I'm trying with external:none or inline:all but looks like the code doesn't support it
https://github.com/developit/microbundle/blob/master/src/index.js#L152
How can I do that using microbundle?
I faced that thing too. ANd it was something strage, exactly because CLI flags and options are not one-on-one match.
I believe removing --target browser and adding --external none would work.
@olstenlarck I tried, but I have the same output:
❯ NODE_ENV=production npx microbundle build --entry lib/index.js --format es,cjs --inline all --external none
Build output to lib:
1.54 kB: index.js
1.54 kB: index.m.js
It seems that this is a bug or a mistake. I think it would be easier to just support external with various types of values and we should get rid of inline as its both undocumented and not available from the CLI options.
I can work on it later today, but if you need it sooner I encourage you to send a PR for this :)
One more thing could be the problem. The plugin -node-resolve should be before the -commonjs, so that it first resolves the deps, then converts them to ESM if they are CJS.
still I didn't find a way to do this ¯_(ツ)_/¯
In my case, adding --external none to the command included packages inside dependencies in the package.json file.
Most helpful comment
It seems that this is a bug or a mistake. I think it would be easier to just support
externalwith various types of values and we should get rid ofinlineas its both undocumented and not available from the CLI options.I can work on it later today, but if you need it sooner I encourage you to send a PR for this :)