JupyterLab extension builder providing webpack-based compilation and build tools for JupyterLab extensions
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Automated webpack configuration generation for JupyterLab extensions with module federation, shared dependencies, asset processing, and development/production optimizations.
Generates complete webpack configurations for building JupyterLab extensions with module federation and shared dependency management.
/**
* Generates webpack configuration for JupyterLab extension building
* @param options - Configuration options for the build
* @returns Array of webpack configuration objects
*/
function generateConfig(options?: IOptions): webpack.Configuration[];
interface IOptions {
/** Path to extension package directory */
packagePath?: string;
/** Path to core JupyterLab package directory */
corePath?: string;
/** URL for build assets if hosted outside the built extension */
staticUrl?: string;
/** Build mode: development or production */
mode?: 'development' | 'production';
/** Source map configuration */
devtool?: string;
/** Whether in watch mode */
watchMode?: boolean;
}The configuration generator provides:
Usage Example:
import generateConfig from "@jupyterlab/builder/lib/extensionConfig";
import * as webpack from "webpack";
// Generate configuration for an extension
const configs = generateConfig({
packagePath: "/path/to/my-extension",
corePath: "/path/to/@jupyterlab/application",
mode: "production",
staticUrl: "https://cdn.example.com/static"
});
// Compile with webpack
const compiler = webpack(configs);
compiler.run((err, stats) => {
if (err) console.error(err);
console.log(stats.toString());
});The generator creates Module Federation configurations that:
./extension and ./mimeExtension based on package.jsonremoteEntry.[contenthash].jsThe system intelligently manages shared dependencies by:
~ to ^ for forward compatibility// Example shared dependency configuration
const shared = {
"@jupyterlab/application": {
requiredVersion: "^4.4.7",
singleton: true,
import: false // Don't bundle, use shared instance
},
"react": {
requiredVersion: "^18.0.0",
singleton: true
}
};The configuration includes comprehensive asset handling:
Mode-Specific Configuration:
// Development configuration
const devConfig = generateConfig({
packagePath: "./",
mode: "development",
devtool: "source-map",
watchMode: true
});
// Production configuration
const prodConfig = generateConfig({
packagePath: "./",
mode: "production",
staticUrl: "https://cdn.example.com"
});Extensions can provide custom webpack configurations that are merged with the generated configuration:
// In package.json
{
"jupyterlab": {
"webpackConfig": "./webpack.config.js"
}
}The custom configuration is merged using webpack-merge after the base configuration is generated.
Extensions can customize shared package behavior:
// In package.json
{
"jupyterlab": {
"sharedPackages": {
"lodash": {
"bundled": false, // Don't bundle, use shared
"singleton": true
},
"moment": false // Exclude from sharing entirely
}
}
}The system respects the outputDir setting in package.json:
// In package.json
{
"jupyterlab": {
"outputDir": "dist"
}
}The extension configuration integrates with the broader build system:
Build.ensureAssets() for asset managementThe generated configurations return an array that can be concatenated with theme configurations from the build utilities for a complete build pipeline.