(id, parent, parentStack)
| 344 | } |
| 345 | }, |
| 346 | onIdentifier(id, parent, parentStack) { |
| 347 | const binding = idToImportMap.get(id.name) |
| 348 | if (!binding) { |
| 349 | return |
| 350 | } |
| 351 | if (isStaticProperty(parent) && parent.shorthand) { |
| 352 | // let binding used in a property shorthand |
| 353 | // { foo } -> { foo: __import_x__.foo } |
| 354 | // skip for destructuring patterns |
| 355 | if ( |
| 356 | !isNodeInPattern(parent) || |
| 357 | isInDestructuringAssignment(parent, parentStack) |
| 358 | ) { |
| 359 | s.appendLeft(id.end, `: ${binding}`) |
| 360 | } |
| 361 | } else if ( |
| 362 | parent.type === 'ClassDeclaration' && |
| 363 | id === parent.superClass |
| 364 | ) { |
| 365 | if (!declaredConst.has(id.name)) { |
| 366 | declaredConst.add(id.name) |
| 367 | // locate the top-most node containing the class declaration |
| 368 | const topNode = parentStack[parentStack.length - 2] |
| 369 | s.prependRight(topNode.start, `const ${id.name} = ${binding};\n`) |
| 370 | } |
| 371 | } else if (parent.type === 'CallExpression') { |
| 372 | s.update(id.start, id.end, binding) |
| 373 | // wrap with (0, ...) to avoid method binding `this` |
| 374 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#method_binding |
| 375 | s.prependRight(id.start, `(0,`) |
| 376 | s.appendLeft(id.end, `)`) |
| 377 | } else if ( |
| 378 | // don't transform class name identifier |
| 379 | !(parent.type === 'ClassExpression' && id === parent.id) |
| 380 | ) { |
| 381 | s.update(id.start, id.end, binding) |
| 382 | } |
| 383 | }, |
| 384 | onImportMeta(node) { |
| 385 | s.update(node.start, node.end, ssrImportMetaKey) |
| 386 | }, |
no test coverage detected