
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
babel-inline-import-loader
Advanced tools
A webpack loader enabling files imported by babel-plugin-inline-import to trigger rebuilds when content changes
A webpack loader enabling files imported by babel-plugin-inline-import to trigger rebuilds when content changes.
First install babel-plugin-inline-import@3.0.0 or later. Then:
npm install babel-inline-import-loader --save-dev
In your webpack config, put 'babel-inline-import-loader'
before 'babel-loader'
:
// webpack.config.js
module.exports = {
// ...
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-inline-import-loader',
{
loader: 'babel-loader',
options: {
plugins: [
['inline-import', {
extensions: ['.txt']
}]
],
// Make sure cacheDirectory is disabled so that Babel
// always rebuilds dependent modules
cacheDirectory: false // default
}
}
]
]
}
};
In Next.js, add the following to your next.config.js
:
module.exports = {
// ...
webpack: (config, { defaultLoaders, dir }) => {
const rulesExceptBabelLoaderRule = config.module.rules.filter(
(rule) => rule.use !== defaultLoaders.babel
);
config.module.rules = [
...rulesExceptBabelLoaderRule,
{
test: /\.(js|jsx)$/,
include: [dir],
exclude: /node_modules/,
use: [
'babel-inline-import-loader',
{
...defaultLoaders.babel,
options: {
...defaultLoaders.babel.options,
// Disable cacheDirectory so that Babel
// always rebuilds dependent modules
cacheDirectory: false,
},
},
],
},
];
return config;
},
};
Run npm start
and open http://localhost:8080/. Edit example.txt and webpack should rebuild and reload the page automatically.
babel-inline-import-loader depends on babel-plugin-inline-import#10, so that a comment block specifying the original module path is included next to the inlined import. For example,
import example from './example.txt';
is compiled to
/* babel-plugin-inline-import './example.txt' */ const example = 'hello world';
babel-inline-import-loader then parses the value './example.txt'
from the comment and includes that file in webpack's dependency graph via this.addDependency
.
FAQs
A webpack loader enabling files imported by babel-plugin-inline-import to trigger rebuilds when content changes
The npm package babel-inline-import-loader receives a total of 327 weekly downloads. As such, babel-inline-import-loader popularity was classified as not popular.
We found that babel-inline-import-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.