MCPcopy Create free account
hub / github.com/gaearon/react-hot-loader / ExportDefaultDeclaration

Function ExportDefaultDeclaration

src/babel.dev.js:104–132  ·  view source on GitHub ↗
(path, state)

Source from the content-addressed store, hash-verified

102 return {
103 visitor: {
104 ExportDefaultDeclaration(path, state) {
105 const { file } = state;
106 // Default exports with names are going
107 // to be in scope anyway so no need to bother.
108 if (path.node.declaration.id) {
109 return;
110 }
111
112 // Move export default right hand side to a variable
113 // so we can later refer to it and tag it with __source.
114 const id = path.scope.generateUidIdentifier('default');
115 const expression = t.isExpression(path.node.declaration)
116 ? path.node.declaration
117 : t.toExpression(path.node.declaration);
118 path.scope.registerDeclaration(
119 path.insertBefore(t.variableDeclaration('const', [t.variableDeclarator(id, expression)]))[0],
120 );
121 path.node.declaration = id; // eslint-disable-line no-param-reassign
122
123 // It won't appear in scope.bindings
124 // so we'll manually remember it exists.
125 state[REGISTRATIONS].push(
126 buildRegistration({
127 ID: id,
128 NAME: t.stringLiteral('default'),
129 FILENAME: t.stringLiteral(file.opts.filename),
130 }),
131 );
132 },
133
134 Program: {
135 enter({ scope, node }, state) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected