Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Aug 12, 2021
1 parent da1fb43 commit caae962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion js/initcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ func toESModuleExports(exp modules.Exports) interface{} {
}
// Maybe check that those weren't set
result["default"] = exp.Default
result["__esModule"] = true // this so babel works with
// this so babel works with the `default` when it transpiles from ESM to commonjs.
// This should probably be removed once we have support for ESM directly. So that require doesn't get support for
// that while ESM has.
result["__esModule"] = true

return result
}
Expand Down Expand Up @@ -331,6 +334,7 @@ func getJSModules() map[string]interface{} {
result := getInternalJSModules()
external := modules.GetJSModules()

// external is always prefixed with `k6/x`
for k, v := range external {
result[k] = v
}
Expand Down
5 changes: 4 additions & 1 deletion js/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ type HasModuleInstancePerVU interface {
NewModuleInstancePerVU() interface{}
}

// IsModuleV2 ... TODO better name
// IsModuleV2 is the interface js modules should implement to get the version 2 of the system
type IsModuleV2 interface {
// NewModuleInstance will get InstanceCore that should provide the module with *everything* it needs and return an
// Instance implementation (embedding the InstanceCore).
// This method will be called for *each* require/import and return an object for VUs.
NewModuleInstance(InstanceCore) Instance
}

Expand Down

0 comments on commit caae962

Please sign in to comment.