-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add "importRuntime" option to "transform-runtime" #356
base: main
Are you sure you want to change the base?
Changes from 3 commits
bb57e79
eceab80
c0d6d3f
b913171
2b2162d
b0e702f
56b9a0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { addDefault } from "@babel/helper-module-imports"; | ||
|
||
let currentTypes = null; | ||
|
||
export function wrapWithTypes(types, fn) { | ||
|
@@ -23,10 +25,30 @@ export function getTypes() { | |
return currentTypes; | ||
} | ||
|
||
export function runtimeProperty(name) { | ||
const runtimeNames = new WeakMap(); | ||
|
||
export function runtimeProperty(name, scope, opts) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that |
||
const t = getTypes(); | ||
|
||
let runtimeId; | ||
if (!opts.importRuntime) { | ||
runtimeId = t.identifier("regeneratorRuntime"); | ||
} else { | ||
const programPath = scope.getProgramParent().path; | ||
if (runtimeNames.has(programPath.node)) { | ||
runtimeId = t.identifier(runtimeNames.get(programPath.node)); | ||
} else { | ||
runtimeId = addDefault(programPath, "regenerator-runtime", { | ||
nameHint: "regeneratorRuntime", | ||
importedInterop: "uncompiled", | ||
blockHoist: 3 | ||
}); | ||
runtimeNames.set(programPath.node, runtimeId.name); | ||
} | ||
} | ||
|
||
return t.memberExpression( | ||
t.identifier("regeneratorRuntime"), | ||
runtimeId, | ||
t.identifier(name), | ||
false | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes were made by lerna I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we revert the lerna changes?