Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
@babel/helpers
tests to ESM (#14753)
* Convert `@babel/helpers` tests to ESM * Run some tests on older versions * Fix * Update jest.config.js
- Loading branch information
1 parent
4f278dc
commit a33ad27
Showing
19 changed files
with
67 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/babel-helpers/test/fixtures/behavior/get-with-falsy-receiver/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"plugins": ["./plugin"] | ||
"plugins": ["./plugin.cjs"] | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/babel-helpers/test/fixtures/behavior/get-without-receiver/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"plugins": ["./plugin"] | ||
"plugins": ["./plugin.cjs"] | ||
} |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
packages/babel-helpers/test/fixtures/dependencies/basic/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/babel-helpers/test/fixtures/dependencies/deep/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/babel-helpers/test/fixtures/dependencies/missing/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/babel-helpers/test/fixtures/dependencies/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"minNodeVersion": "12.22.0", | ||
"externalHelpers": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/babel-helpers/test/fixtures/dependencies/rename-deep-global/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/babel-helpers/test/fixtures/dependencies/reuse-dependency/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/babel-helpers/test/fixtures/regression/9496/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"minNodeVersion": "12.22.0", | ||
"plugins": ["./plugin"] | ||
} |
6 changes: 3 additions & 3 deletions
6
packages/babel-helpers/test/fixtures/regression/9496/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import path from "path"; | ||
import _template from "@babel/template"; | ||
import _helpers from "../../lib/helpers.js"; | ||
const template = _template.default || _template; | ||
const helpers = _helpers.default || _helpers; | ||
|
||
function getHelperId(baseURL, name) { | ||
const testName = path.basename(new URL(".", baseURL).pathname); | ||
return `_$_${testName}_${name}`; | ||
} | ||
|
||
export default function defineHelper(baseURL, name, code) { | ||
const id = getHelperId(baseURL, name); | ||
if (id in helpers) { | ||
throw new Error(`The ${id} helper is already defined.`); | ||
} | ||
Object.defineProperty(helpers, id, { | ||
value: { | ||
minVersion: "7.0.0-beta.0", | ||
ast: template.program(code), | ||
}, | ||
}); | ||
return id; | ||
} |