babel 7 configuration format
See original GitHub issueHi there,
I’m trying to bumble my way through to having a working babel7-based setup but there seems to be something wrong the moment i pull in “babel-plugin-inline-import-graphql-ast”
Here is my babel.config.js
(this is now the babel7 method to specify a project-wide babel config, in lieu of .babelrc
):
// https://github.com/babel/babel/pull/7358#issuecomment-388311941
module.exports = {
overrides: [{
test: '*',
presets: [
['@babel/preset-env', {'node': 'current'}],
],
plugins: [
[
"babel-plugin-inline-import",
{
extensions: [
".css"
]
}
],
"babel-plugin-inline-import-graphql-ast"
],
env: {
development: {
presets: [
"next/babel",
]
},
production: {
presets: [
[
"next/babel",
{
["preset-env"]: {
targets: {
browsers: "> 5%"
}
}
}
]
]
},
test: {
presets: [
[
"next/babel",
{
["preset-env"]: {
modules: true
}
}
]
]
}
}
}],
ignore: [
"/*.plain/"
]
}
Example usage of the graphql inlining:
# ---- https://github.com/apollographql/graphql-tag
#import "./Category3Fragment.graphql"
#import "./Category2Fragment.graphql"
#import "./Category1Fragment.graphql"
query Category1(
$canonicalised_name: String,
$category1__canonicalised_name: String,
) {
category1 (
canonicalised_name: $canonicalised_name,
category1__canonicalised_name: $category1__canonicalised_name,
) {
...Category1Fragment
}
}
Error text:
Module build failed: Error: Configuration contains explicit test/include/exclude checks, but no filename was passed to Babel
at configFieldIsApplicable (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/config-chain.js:401:11)
at configIsApplicable (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/config-chain.js:396:41)
at forEach (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/config-chain.js:242:13)
at Array.forEach (<anonymous>)
at /Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/config-chain.js:239:42
at buildRootChain (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/config-chain.js:90:20)
at loadPrivatePartialConfig (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/partial.js:51:55)
at loadFullConfig (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/config/full.js:43:39)
at transformSync (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/lib/transform-sync.js:15:38)
at buildVariableAST (/Users/matt/dev/partridge/frontend/node_modules/babel-plugin-inline-import-graphql-ast/build/index.js:87:58)
at /Users/matt/dev/partridge/frontend/node_modules/babel-plugin-inline-import-graphql-ast/build/index.js:72:26
at Array.map (<anonymous>)
at buildReplacements (/Users/matt/dev/partridge/frontend/node_modules/babel-plugin-inline-import-graphql-ast/build/index.js:65:31)
at PluginPass.exit (/Users/matt/dev/partridge/frontend/node_modules/babel-plugin-inline-import-graphql-ast/build/index.js:59:34)
at newFn (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:237:21)
at NodePath._call (/Users/matt/dev/partridge/frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:65:20)
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Config Files - Babel.js
Babel can be configured using any file extension natively supported by Node.js, as mentioned in Configuration File Types section: babel.config.json and .babelrc ...
Read more >Babel 7: Configuration, Preset, and Plugin Usage
Although structurally different from the original file, it is code that will work in current browsers and the Node.js platform. @ babel /...
Read more >Configuring Babel 7 - YouTube
How Babel 7 configuration works.Repo: https://github.com/kentcdodds/babel- config -exampleDocs: ...
Read more >The New Babel 7 Config - Maria D. Campbell
ended up that I had to ; change my ; Babel 7 configuration file from .babelrc to babel.config.js . ; Babel 7 ;...
Read more >Working with Babel 7 and Webpack | The Basement
We will need a couple of different things to set up Babel: a couple of npm-packages , a .babelrc -file and a .browserslistrc...
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
Nope! It’s a brand new feature in Babel 7, so I can’t imagine anyone would be relying on it, and your code already skips reading
.babelrc
files since the JS snippet doesn’t have a filename.This line https://github.com/detrohutt/babel-plugin-inline-import-graphql-ast/blob/678284600731bc77b632766f969a6033d9304700/plugin/index.js#L54 will attempt to load the user’s
babel.config.js
file too, because it is not passingconfigFile: false
when callingtransformSync
.My recommendation would be to drop the usage of
transformSync
entirely.should expand to
and then
can be