Skip to content
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

Support for node modules resolution #475

Closed
ludeknovy opened this issue Jan 19, 2018 · 4 comments
Closed

Support for node modules resolution #475

ludeknovy opened this issue Jan 19, 2018 · 4 comments
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 feature js-compat

Comments

@ludeknovy
Copy link

Use case:
I have a package with contains all of my api calls. I use them for functional tests. But this package itself is dependent on another external package. It would be really helpful If I could reuse this package across functional and performance tests.

@robingustafsson
Copy link
Member

Thanks @ludeknovy for creating an issue for this.

Looked a bit again at this today. I think we should aim for supporting more of node's dependency resolution algorithm then we do today (https://nodejs.org/api/modules.html#modules_all_together). We support parts of it but there are several large gaps. We won't support all of the steps since they don't make sense outside of node but we can definitely expand to cover more parts of it.

@san-slysz
Copy link

I agree. I faced the same issue. Here's the 2 aspects I mainly lack:

  • being able to use path/module instead of path/index.js (not having to explicite index)
  • being able to use path/module/file instead of path/module/file.js (not having to explicite extension)

Hopefully this will naturally come with the feature :).

@na-- na-- added this to the v1.0.0 milestone Oct 15, 2018
@na--
Copy link
Member

na-- commented Dec 27, 2018

Some docs that have to be reviewed before we proceed with this:

@na-- na-- added the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Jul 11, 2019
@na-- na-- removed this from the v1.0.0 milestone Aug 27, 2019
@na--
Copy link
Member

na-- commented Jan 21, 2021

I am closing this, since it's very unlikely for k6 to ever support the old node module resolution algorithm. As shown in the links above, NodeJS themselves are getting rid of it with their new modules support. And if anyone wants it, it's very easy to setup a webpack pipeline to resolve and bundle old-node-style modules like this: https://github.com/k6io/template-es6

It even has the added bonus of easily being able to transform the scripts with Babel in the same pipeline, making them suitable for k6's base compatibility mode and benefiting from the resulting improved performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 feature js-compat
Projects
None yet
Development

No branches or pull requests

4 participants