Skip to content

Commit

Permalink
Don't mix ESM and CommonJS in shim/dynamic.js (#131)
Browse files Browse the repository at this point in the history
It seems that at some point when this was written someone mixed ESM and
CommonJS syntax.

There is not good reason to do this, and it will soon not be supported -
and arguably has never been, it just happened to work due to how ESM was
supported in k6.

See grafana/k6#3807 and linked issues/PRs
  • Loading branch information
mstoykov committed Jun 27, 2024
1 parent 68216ec commit 2af49cb
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/shim/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const DIRECTORY_PATHS = [
];

// generators for $random* variables
const dynamicGenerators = {
export const dynamicGenerators = {
// Skipped from Postman
$guid: {
description: 'A v4 style guid',
Expand Down Expand Up @@ -756,7 +756,7 @@ const dynamicGenerators = {
// It will look like this: /\{\{\$guid\}\}|\{\{\$timestamp\}\}|\{\{\$isoTimestamp\}\}/g
// It can then be used to match templates containing generators
// for example with the replaceIn function
const dynamicGeneratorsRegex = (function() {
export const dynamicGeneratorsRegex = (function() {
let generatorRegexString = '';
for (const [key, value] of Object.entries(dynamicGenerators)) {
generatorRegexString += '{{' + key + '}}' + '|';
Expand All @@ -770,8 +770,3 @@ const dynamicGeneratorsRegex = (function() {
const generatorRegex = new RegExp(generatorRegexString, 'g');
return generatorRegex;
})();

module.exports = {
dynamicGenerators,
dynamicGeneratorsRegex,
};

0 comments on commit 2af49cb

Please sign in to comment.