Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect module path when absoluteRuntime is specified #11893

Merged
merged 5 commits into from Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/babel-plugin-transform-runtime/package.json
Expand Up @@ -35,6 +35,7 @@
"@babel/plugin-transform-typeof-symbol": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/runtime": "^7.10.5",
"@babel/runtime-corejs3": "^7.10.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to fix the e2e error: https://app.circleci.com/pipelines/github/babel/babel/3524/workflows/90153e91-f615-4930-8a0f-5ed243d3a6cc/jobs/26605/parallel-runs/0/steps/0-103

The error is thrown because @babel/runtime-corejs3 is not hoisted to the top level in e2e-test. The other test is passing because @babel/runtime-corejs3 is hoisted to the top level from fixture locations, this is not guaranteed and dev deps should be declared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

"@babel/template": "^7.10.4",
"@babel/types": "^7.10.5"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-runtime/src/index.js
Expand Up @@ -310,7 +310,7 @@ export default declare((api, options, dirname) => {
node.callee = t.memberExpression(
t.callExpression(
this.addDefaultImport(
`${moduleName}/${corejsRoot}/instance/${InstanceProperties[propertyName].path}`,
`${modulePath}/${corejsRoot}/instance/${InstanceProperties[propertyName].path}`,
`${propertyName}InstanceProperty`,
),
[context2],
Expand Down Expand Up @@ -379,7 +379,7 @@ export default declare((api, options, dirname) => {
path.replaceWith(
t.callExpression(
this.addDefaultImport(
`${moduleName}/core-js/get-iterator-method`,
`${modulePath}/core-js/get-iterator-method`,
"getIteratorMethod",
),
[object],
Expand Down Expand Up @@ -407,7 +407,7 @@ export default declare((api, options, dirname) => {
path.replaceWith(
t.callExpression(
this.addDefaultImport(
`${moduleName}/${corejsRoot}/instance/${InstanceProperties[propertyName].path}`,
`${modulePath}/${corejsRoot}/instance/${InstanceProperties[propertyName].path}`,
`${propertyName}InstanceProperty`,
),
[object],
Expand Down
@@ -0,0 +1,8 @@
Array.map;
function* makeIterator() {
yield 1;
yield 2;
}
for (const itItem of makeIterator()) {
console.log(itItem);
}
@@ -0,0 +1,7 @@
{
"presets": ["env"],
"plugins": [
["transform-runtime", { "absoluteRuntime": true, "corejs": { "version": 3, "proposals": true } }],
["external-helpers", { "helperVersion": "7.100.0" }]
]
}
@@ -0,0 +1,41 @@
var _regeneratorRuntime = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime-corejs3/regenerator");

var _mapInstanceProperty = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime-corejs3/core-js/instance/map");

var _marked = /*#__PURE__*/_regeneratorRuntime.mark(makeIterator);

_mapInstanceProperty(Array);

function makeIterator() {
return _regeneratorRuntime.wrap(function makeIterator$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return 1;

case 2:
_context.next = 4;
return 2;

case 4:
case "end":
return _context.stop();
}
}
}, _marked);
}

var _iterator = babelHelpers.createForOfIteratorHelper(makeIterator()),
_step;

try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var itItem = _step.value;
console.log(itItem);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
@@ -0,0 +1,8 @@
Array.map;
function* makeIterator() {
yield 1;
yield 2;
}
for (const itItem of makeIterator()) {
console.log(itItem);
}
@@ -0,0 +1,7 @@
{
"presets": ["env"],
"plugins": [
["transform-runtime", { "absoluteRuntime": true, "corejs": { "version": 3, "proposals": false } }],
["external-helpers", { "helperVersion": "7.100.0" }]
]
}
@@ -0,0 +1,41 @@
var _regeneratorRuntime = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime-corejs3/regenerator");

var _mapInstanceProperty = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime-corejs3/core-js-stable/instance/map");

var _marked = /*#__PURE__*/_regeneratorRuntime.mark(makeIterator);

_mapInstanceProperty(Array);

function makeIterator() {
return _regeneratorRuntime.wrap(function makeIterator$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return 1;

case 2:
_context.next = 4;
return 2;

case 4:
case "end":
return _context.stop();
}
}
}, _marked);
}

var _iterator = babelHelpers.createForOfIteratorHelper(makeIterator()),
_step;

try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var itItem = _step.value;
console.log(itItem);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}