-
Notifications
You must be signed in to change notification settings - Fork 30
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
codegen seems to be running before other plugins regardless of order? #1
Comments
Yeah, let me fix that... Congrats on being issue #1! 🎉 |
So we don't run into issues like kentcdodds/babel-plugin-codegen#1
Could you try the latest version and let me know if that fixes your issue? Thanks! |
thanks for the quick reply, same thing though, using ~
❯ echo "// @codegen\nimport fs from 'fs';" >> foo.js
~
❯ babel --plugins=transform-es2015-modules-commonjs,codegen foo.js
SyntaxError: foo.js: Unexpected token import
undefined
~
❯ babel --plugins=transform-es2015-modules-commonjs foo.js
'use strict';
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
Hmm.... Weird! Could you add a test case in the tests? That would help us figure out what's going on... |
I don't see any tests? |
Ah yes, if you could remove The tests are here. Probably best to just put it here at the bottom. Something like: 'pragma on a file can handle ES6 imports': {
skip: true, // until we get this test passing
code: `
// codegen
import fs from 'fs'
`
} That make sense? |
Oh, and you can run the tests in watch mode with |
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),
},
}; |
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. |
So we don't run into issues like kentcdodds/babel-plugin-codegen#1
In short, I'm having this issue:
the above throws
unexpected token import
, if I remove the// @codegen
line it works fine. My babel plugins are:I'd expect that
codegen
would get code transformed fromtransform-es2015-modules-commonjs
and then execute that, but it doesn't seem to be the case. Thoughts?The text was updated successfully, but these errors were encountered: