Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some comments
Browse files Browse the repository at this point in the history
mstoykov committed Aug 12, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent da1fb43 commit caae962
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
@@ -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
}
@@ -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
}
5 changes: 4 additions & 1 deletion js/modules/modules.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit caae962

Please sign in to comment.