Adding this plugin to the plugin list breaks other Babel functionality
See original GitHub issueHi @leonardfactory, I noticed that when I add this plugin to my plugin list it breaks the other transformations in the config. I get this error message when it’s in there:
C:\Users\Robbie\Code\ginger\src\backend\resolvers\RecipeResolver.ts:1
(function (exports, require, module, __filename, __dirname) { import {
^
SyntaxError: Unexpected token {
This is the same error message I get if I do not use Babel at all (or remove the react-app
preset). If I don’t use the plugin, metadata reflection doesn’t work (and TypeORM gives me errors) but everything else does. My package.json babel config is this:
"babel": {
"plugins": [
"babel-plugin-transform-typescript-metadata",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator"
],
"presets": [
"react-app"
]
}
If you need more information, my project repository is here: https://github.com/RobbieGM/ginger Thanks for your help!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Plugins List - Babel.js
JavaScript. TC39 Proposals. decorators · do-expressions · duplicate-named-capturing-groups-regex · export-default-from · export-namespace-from · function- ...
Read more >Options - Babel.js
Primary options; Config Loading options; Plugin and Preset configuration ... This option allows users to provide a list of other packages that should...
Read more >babel/preset-env
@babel/preset-env takes any target environments you've specified and checks them against its mappings to compile a list of plugins and passes it to...
Read more >babel/plugin-transform-typescript
This plugin adds support for the types syntax used by the TypeScript programming language. However, this plugin does not add the ability to...
Read more >Upgrade to Babel 7 (API)
Dropped use of add-module-exports plugin on Babel packages. This had to be used earlier to prevent a breaking change with our exports. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, I think you need at least the preset
@babel/preset-typescript
for this to work, probably even@babel/plugin-proposal-decorators
and@babel/plugin-proposal-class-properties
.See the usage section for more.
Don’t forget to close this issue, if this helped you. Cheers!
It works just fine the way it’s configured when run with
ts-node
but breaks when babel is involved. I’ll give it a try with direct entity class assignment as described. Also, @wtho TypeORM uses decorators andreflect-metadata
magic to read types from sources. An example of a class written for TypeORM: