grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
25.04k stars 1.24k forks source link

Importing Errors in ES6 modules #707

Closed chrisgodsey closed 5 years ago

chrisgodsey commented 6 years ago

I've been having a few different issues importing from ES6 modules that have otherwise worked that have had me to refactor some of my existing code in order to get it working with K6.

  1. Importing from files requires the .js file extension when an ES6 module ordinarilly would not.

Example - if my module is written to: import ClassName from './classFile'; I will receive the error that 'The system cannot find the file specified', if I change this line to import ClassName from './classFile.js'; it works fine

  1. Importing from index files does not seem to work appropriately.

Example, if I have any kind of indexing file that may be common in ES modules:

import Class1 from './class1File.js'; import Class2 from './class2File.js';

export default { Class1, Class2 };

if I attempt to import the above file and then create new instances of Class1 and Class2 (as I would be able to normally in an ES6 module), I cannot - however, if I directly import them from class1File and class2File, I am able to do so

na-- commented 5 years ago

The first issue is also duplicated in https://github.com/loadimpact/k6/issues/475 and https://github.com/loadimpact/k6/issues/778, while the second one may be somewhat related to https://github.com/loadimpact/k6/issues/659.

mstoykov commented 5 years ago

I am closing this as this was most likely fixed in #1099 merged with commit bd6d2d958a9f34a89bbbddccae3ba3604d605222 . I did try to reproduce this bug in previous versions ... but it worked all the way back to 0.19.0 and I decided that probably my example isn't using what is broken.

If this is still not resolved please reopen the issue and provide a full example that fails.

mstoykov commented 5 years ago

The code I ran can be find in this gist