webpack-core
raw JSON → 0.6.9 verified Sat Apr 25 auth: no javascript deprecated
The shared core of webpack and enhanced-require, encapsulating loader mechanics and SourceMap handling. Version 0.6.9 is the latest (no longer maintained; last release 2014). It is not intended as a standalone module but provides infrastructure for custom loaders and plugins. Webpack 1.x used this; later versions replaced it with webpack-sources and internal refactoring. Key differentiator: it was the foundational runtime for webpack's loader pipeline before being absorbed into webpack proper. Requires Node >=0.6.
Common errors
error Cannot find module 'webpack-core' ↓
cause Package not installed; webpack-core is internal and not published separately.
fix
Install webpack (includes webpack-core internally).
error Module not found: Error: Cannot resolve module 'webpack-core/lib/SourceMapSource' ↓
cause Incorrect import path.
fix
Use: const SourceMapSource = require('webpack-core').SourceMapSource;
Warnings
deprecated webpack-core is no longer maintained. Use webpack >= 2.0 which includes its own core. ↓
fix Upgrade to webpack 2 or later.
gotcha Not a standalone module; requires webpack context. ↓
fix Do not import directly; use webpack's public API.
Install
npm install webpack-core yarn add webpack-core pnpm add webpack-core Imports
- SourceMapSource wrong
const SourceMapSource = require('webpack-core').SourceMapSource;correctimport { SourceMapSource } from 'webpack-core' - RawSource wrong
const RawSource = require('webpack-core');correctimport { RawSource } from 'webpack-core' - ModuleFilenameHelpers wrong
import ModuleFilenameHelpers from 'webpack-core';correctimport { ModuleFilenameHelpers } from 'webpack-core'
Quickstart
const webpack = require('webpack');
const config = {
entry: './src/index.js',
output: { path: './dist', filename: 'bundle.js' },
module: { loaders: [{ test: /\.js$/, loader: 'babel' }] },
plugins: []
};
webpack(config, (err, stats) => {
if (err) console.error(err);
else console.log(stats.toString());
});