-
Notifications
You must be signed in to change notification settings - Fork 29.1k
chore: Update babel types and do some light cleanup of babel loader #82486
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,12 +70,7 @@ export default function ({ | |
;[newPath] = path.unshiftContainer('body', mapping) | ||
} | ||
|
||
for (const declar of newPath.get('declarations')) { | ||
path.scope.registerBinding( | ||
newPath.node.kind, | ||
declar as NodePath<BabelTypes.Node> | ||
) | ||
} | ||
path.scope.registerDeclaration(newPath) | ||
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. This is equivalent, but correctly handles the new |
||
} | ||
|
||
if (!existingBinding) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ export default function ({ | |
let callExpression = refPath.parentPath | ||
|
||
if ( | ||
callExpression.isMemberExpression() && | ||
callExpression?.isMemberExpression() && | ||
callExpression.node.computed === false | ||
) { | ||
const property = callExpression.get('property') | ||
|
@@ -74,14 +74,11 @@ export default function ({ | |
} | ||
} | ||
|
||
if (!callExpression.isCallExpression()) return | ||
if (!callExpression?.isCallExpression()) return | ||
|
||
const callExpression_ = | ||
callExpression as NodePath<BabelTypes.CallExpression> | ||
Comment on lines
-79
to
-80
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.
|
||
|
||
let args = callExpression_.get('arguments') | ||
let args = callExpression.get('arguments') | ||
bgw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (args.length > 2) { | ||
throw callExpression_.buildCodeFrameError( | ||
throw callExpression.buildCodeFrameError( | ||
'next/dynamic only accepts 2 arguments' | ||
) | ||
} | ||
|
@@ -97,10 +94,10 @@ export default function ({ | |
options = args[0] | ||
} else { | ||
if (!args[1]) { | ||
callExpression_.node.arguments.push(t.objectExpression([])) | ||
callExpression.node.arguments.push(t.objectExpression([])) | ||
} | ||
// This is needed as the code is modified above | ||
args = callExpression_.get('arguments') | ||
args = callExpression.get('arguments') | ||
loader = args[0] | ||
options = args[1] | ||
} | ||
|
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.
The can't be part of
types.d.ts
because we get type errors in the generated declarations afternext build
from trying to accessnext/dist/compiled/babel/core
?I don't really understand enough about the limitations of generated declaration files.