-
-
Notifications
You must be signed in to change notification settings - Fork 13
WIP: Automatically insert node_modules as externals #22
Conversation
NOTE: I had a really hard time testing this locally, I couldn't just remove the package (in Not sure if this is to do with how the |
@kazupon After thinking about this further the above mentioned config file is the only way I can think of the solves this problem, I am happy to tool this out but I would like confirmation that this is the right direction for the project before I write any additional code. If it is not please let me know what you think and I can start working on an alternative solution. |
Thank you for your PR! |
I will be appreciated if I can specify that a dependency x should be bundled during plugin build or not, because now they are all excluded by default. |
@CrashyBang To add APIs and configuration file to vue-cli-plugin-p11n, JavaScript module dependencies becomes more complicated. In about #1, I wanted to support importing customized |
@kazupon sounds good to me, so with that in mind do we still want to use what I have to automatically populate the externals via the |
@CrashyBang If the user don't expect the resolution behavior of module dependencies, I think that want to be able to fully control it with rollup.config.js What do you think about it? As I noticed now, Vue CLI supports vue.config.js, so if you set it as a plug-in option as shown below, it seems that extra configuration files will not increase. |
Hey @kazupon, Sorry for the delay in my response, yes I totally agree if a In regards to setting a Cheers! |
@CrashyBang
I've updated #1 |
Hey @kazupon I like that! Should wait for that functionality to exist before we merge this in? |
@CrashyBang At first, let's merge this PR! |
@CrashyBang |
Hey @kazupon it all works so I am happy to merge it in, before we do though, I was wondering if this is the best way to reference the const { dependencies } = require(path.resolve(process.cwd(), 'package.json')) Otherwise I am happy to merge! |
As per #21 I am submitting a PR to allow the use of external libraries (such as
axios
) without having to include them in the final bundle.The code I have submitted does work, however there are some caveats that I think need to be addressed before we merge.
npm
without the--save
flag it will not be included in the projectsdependencies
and as such will not be made automatically made external.dependencies
) I think an API should be made available to do this, and it can be merged with the automatically generated externals.esm
andumd
modules require a global to be set when using externals (see here) Rollup does it's best to guess what the global name should be, but an API should be provided where a user can manually specify these if needed (there are some examples here of when guessing does not work).If you are interested in the difference between global and external see here.
Based on these requirements I suggest we add some sort of config file (
.p11nrc
for example) with the following options (assumingJSON
style format):The way I see this working or the flow would be as follows:
dependencies
.externalBlacklist
from constructed list.dependencies
externals to the constructed list.A rough example is below (using
lodash
):