Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

codegen seems to be running before other plugins regardless of order?

See original GitHub issue

In short, I’m having this issue:

// @codegen

import fs from 'fs';

the above throws unexpected token import, if I remove the // @codegen line it works fine. My babel plugins are:

 ['transform-es2015-modules-commonjs', 'transform-flow-comments', 'codegen']

I’d expect that codegen would get code transformed from transform-es2015-modules-commonjs and then execute that, but it doesn’t seem to be the case. Thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

kentcdoddscommented, Jun 29, 2018

babel-plugin-codegen no longer runs your codegen-source code through babel. It must be written in code that’s supported natively in the version of node you’re running.

linonetwocommented, Jun 29, 2018

I get

SyntaxError: Unexpected token, expected ";" (2:84)
      1 | /* @babel/template */;
    > 2 | {lastNameClose: ({ lastNameClose }) => new Date(lastNameClose),lastPervoteBucketFill: ({ lastPervoteBucketFill }) => new Date(lastPervoteBucketFill)}
        |                                                                                    ^

Trying to do so:

export const GlobalStatus = {
  ...codegen`module.exports = '{' + ['lastNameClose', 'lastPervoteBucketFill'].map(field =>
    \`\${field}: ({ \${field} }) => new Date(\${field})\`
  ).join(',') + '}'`,
// to
export const GlobalStatus = {
    lastNameClose: ({ lastNameClose }) => new Date(lastNameClose),
    lastPervoteBucketFill: ({ lastPervoteBucketFill }) => new Date(lastPervoteBucketFill),
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using babel-plugin-codegen to generate boilerplate ... - Medium
babel-plugin-codegen. The plugin runs at build time (in my case via webpack / babel-loader ), generating a string of code from code and ......
Read more >
Widget Code Generator by Figma
Run the plugin. Once you have Widget Code Generator installed, you can run it a few different ways: Right-click on the canvas >...
Read more >
Maven is not working in Java 8 when Javadoc tags are ...
Any workaround about how to build the sources, install the project and generate the Javadoc JAR in one step as it was working...
Read more >
Introducing GraphQL Code Generator – The Guild
I wrote the code generator based on my experience with other robust code generators (such as Swagger codegen). You can create your own...
Read more >
RTI Code Generator User's Manual
On Windows systems: Before running rtiddsgen, run VCVARS32.BAT in the same command prompt that you will use to run rtiddsgen. The VCVARS32.BAT file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found