-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
breaking changefor PRs that need to be mentioned in the breaking changes section of the release notesfor PRs that need to be mentioned in the breaking changes section of the release notesjs-compatrefactor
Description
I think we should deprecate JS extensions (i.e. extensions to the JS API written in Go 😅) that don't implement the JS Module
interface:
Lines 27 to 32 in 1993ac1
// Module is the interface js modules should implement in order to get access to the VU | |
type Module interface { | |
// NewModuleInstance will get modules.VU that should provide the module with a way to interact with the VU | |
// This method will be called for *each* require/import and should return an unique instance for each call | |
NewModuleInstance(VU) Instance | |
} |
JS Modules that don't implement this API are basically an interface{}
that is directly given to goja to deal with. For some historical context:
- all k6 modules used to be like that a long time ago
- however, we have had the new Module API since k6 v0.34.0/v0.35.0 (~1.5 years ago, see common.bind replacement #2108 Modules fixes #2234)
- after that, all native JS modules were moved to the new module interface
- we dropped the common.Bind() interface that old JS modules used to get the VU information in k6 v0.38.0 (May 2022, almost a year ago); at this point, most of the "simple" JS extensions needed to be rewritten if they wanted to send metrics or do anything that involved working with k6
At this point, unless we have a specific reason to support these interface{}
JS modules I don't know about, I think it's fine to officially and fully deprecate them, right?
My proposal is that:
- We simplify the xk6 JS extension docs - completely remove this section from the documentation now and only give an example on how the new Module API is used, i.e. move this section to the top.
- In k6 v0.44.0, we announce the deprecation of the old modules explicitly mark all built-in modules to the new type (i.e. make this map from
map[string]interface{}
tomap[string]modules.Module
) and start emitting a warning if such an xk6 extension module is used that doesn't implement it. - Maybe add a warning in xk6 when an old k6 version is used during the build process (Warn when old k6 version is used xk6#52).
- In k6 v0.45.0 or v0.46.0, we completely remove that capability from k6 to run the old
interface{}
modules, the js/modules.Register() method will start requiringa modules.Module
as an argument and any old JS extensions will need to be rewritten.
Metadata
Metadata
Assignees
Labels
breaking changefor PRs that need to be mentioned in the breaking changes section of the release notesfor PRs that need to be mentioned in the breaking changes section of the release notesjs-compatrefactor