Babel plugin that allows importing raw file contents as strings during transpilation. Version 3.0.0 supports importing files with extensions like .raw, .text, .graphql, with configurable extension mapping. It replaces import statements with the file's literal content, enabling use cases like embedding GraphQL schemas or SQL queries without separate file reading. Differentiates from webpack raw-loader by operating at the Babel level, working with babel-node and babel-register. Caveat: Babel does not track dependencies for imported files, requiring cache disabling or watcher configuration.
npm install babel-plugin-inline-importVerified import paths — ran on the pinned version, not inferred.
Configures the plugin to process .graphql and .sql files, then imports a .graphql file as a string.
Disable Babel cache with BABEL_DISABLE_CACHE=1 when using babel-node or babel-register. For webpack, use babel-inline-import-loader to force recompilation.
Always use default import syntax: import x from 'file.graphql'
Remove any 'extend' option from plugin configuration; wrap content manually if needed.
Add babel-inline-import-loader or ensure the file is processed by Babel before webpack: use babel-inline-import-loader in webpack config.
Add the extension to the plugin options: { plugins: [["babel-plugin-inline-import", { extensions: [".graphql"] }]] }Replace require() with ES6 import syntax: import content from './file.graphql'
No dependency data recorded yet.