Registry / devops / babel-inline-import-loader

babel-inline-import-loader

JSON →
library1.0.1jsnpmunverified

A webpack loader that integrates with babel-plugin-inline-import to ensure file imports via the plugin trigger webpack rebuilds on content changes. Version 1.0.1 is current, with no recent updates since 2020. Releases are infrequent, focusing on bug fixes. Unlike alternative approaches that require manual watchers, this loader leverages webpack's addDependency API for automatic rebuilds. Requires babel-plugin-inline-import@3.0.0+ and webpack. Primarily used with babel-loader in JavaScript projects.

npm install babel-inline-import-loader
INSTALL
IMPORT
SIG · BABEL-INLINE-IMPOR
B
babel-inline-import-loader
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = require('babel-inline-import-loader')
import loader from 'babel-inline-import-loader'
This package is a webpack loader, not a JavaScript module. Use require() in webpack config. No default export.

Demonstrates basic webpack configuration to enable file imports via babel-plugin-inline-import with automatic rebuilds.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: [ 'babel-inline-import-loader', { loader: 'babel-loader', options: { plugins: [ ['inline-import', { extensions: ['.txt'] }] ], cacheDirectory: false } } ] } ] } }; // Note: Ensure babel-plugin-inline-import@>=3.0.0 is installed.
Debug
Known issues
gotchaMust disable babel-loader cacheDirectory (set to false) to ensure rebuilds on inline-import file changes.
fix
Set 'cacheDirectory: false' in babel-loader options.
affects: >=1.0.0
gotchaRequires babel-plugin-inline-import@3.0.0 or later for comment generation support.
fix
Upgrade babel-plugin-inline-import to version 3.0.0 or later.
affects: >=1.0.0
gotchaLoader order matters: babel-inline-import-loader must be placed before babel-loader in the use array.
fix
Ensure use array order: ['babel-inline-import-loader', { loader: 'babel-loader', options: {...} }]
affects: >=1.0.0
gotchaThe loader only processes files with the pattern '/* babel-plugin-inline-import '<path>' */' comments; custom plugin versions may not include the comment.
fix
Confirm babel-plugin-inline-import generates the expected comment.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'babel-inline-import-loader'
Loader is not installed or not in node_modules.
fix
Run 'npm install babel-inline-import-loader --save-dev'
Error: The loader 'babel-inline-import-loader' is not a function
Incorrect import (e.g., using ESM import instead of require) or path issue.
fix
Use require in webpack config: const loader = require('babel-inline-import-loader');
babel-plugin-inline-import: Unknown plugin "inline-import" specified in ...
babel-plugin-inline-import not installed or not specified correctly.
fix
Install babel-plugin-inline-import@>=3.0.0 and add to babel plugins.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
babel-plugin-inline-importrequiredPeer dependency required for the inline import transformation; loader relies on the comment generated by the plugin.
Agent activity
8 hits · last 30 days
node
6
Perplexity
1
Resources
babel-inline-import-loader — npm install babel-inline-import-loader · libregistry