Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Dynamically create a lib.js bundle if external browserified node libraries are required #3

Closed
robingustafsson opened this issue Feb 7, 2019 · 11 comments

Comments

@robingustafsson
Copy link
Member

robingustafsson commented Feb 7, 2019

To make the experience smoother when installing this tool from NPM (not yet published as of Feb 7th 2018) we should improve how browserified node libraries are used.

Today one needs to run ./bundle, after cloning the repo and installing the node dependencies, to download and browserify the necessary node libs to bridge the gap between feature sets in JMeter and k6. The generated k6 JS code then refers to these browserified libraries via import libName from "./build/libName.js".

I propose we instead bundle browserified versions of the possible dependant node libraries and then use browserify or webpack as part of the conversion process to create a jmeter-compat.js file that we output to the CWD where the jmeter-to-k6 <input> > <output> is run.

The lib.js file would then be used like this: import { papaparse, jsonpath } from "./jmeter-compat.js"

I propose we also add a -o filename flag to the CLI to support specifying where the generated JS script should be saved, and thus also the jmeter-compat.js file.

@robingustafsson
Copy link
Member Author

@bookmoons Would you be interested in this as a bounty? If so, PM me on Slack.

@bookmoons
Copy link
Contributor

Thank you for the offer. Yes I'm interested. Sent a PM on Slack.

@bookmoons
Copy link
Contributor

I'm getting into this today.

@robingustafsson
Copy link
Member Author

Perfect! I'll set up the bounty.

@robingustafsson
Copy link
Member Author

Bounty link: https://www.bountysource.com/issues/69756182-dynamically-create-a-lib-js-bundle-if-external-browserified-node-libraries-are-required

@bookmoons
Copy link
Contributor

Do you think it makes sense to prebundle everything? Tentatively doing it that way in #7. file/jmeter-compat.js includes everything, and it gets deployed with conversions.

@robingustafsson
Copy link
Member Author

Unfortunately, I think we'll need to create the final jmeter-compat.js bundle at point of conversion, including only the necessary deps. The reason being that each VU in a k6 test will load this file, parse it and create all the necessary JS structures in memory. Just the source of jmeter-compat.js seems to weigh in at ~1.25 MB, once loaded into each VU's VM this will be much more. So, we need to avoid as much JS code as possible.

I'm not an expert at browserify or webpack and similar tools, but maybe we could have one big bundle that is prebuilt and just filter out the modules not needed at conversion time?

@bookmoons
Copy link
Contributor

Alright, will look into it.

@bookmoons
Copy link
Contributor

Have to put this aside. It'll be a while before I can get back to it.

@robingustafsson
Copy link
Member Author

@bookmoons Ok, let me know when you get back to it. Sent you a slack message as well 🙂

@bookmoons
Copy link
Contributor

This has been resolved by #13 and could be closed.

@simskij simskij closed this as completed Feb 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants