JupyterLab extension builder providing webpack-based compilation and build tools for JupyterLab extensions
npx @tessl/cli install tessl/npm-jupyterlab--builder@4.4.0JupyterLab Builder is a comprehensive build toolchain specifically designed for compiling and building JupyterLab extensions. It provides webpack-based build infrastructure with TypeScript compilation, asset processing, module federation, and custom plugins for the JupyterLab ecosystem.
npm install @jupyterlab/builderimport { Build, WPPlugin } from "@jupyterlab/builder";For CommonJS:
const { Build, WPPlugin } = require("@jupyterlab/builder");For extension configuration:
import generateConfig from "@jupyterlab/builder/lib/extensionConfig";import { Build, WPPlugin } from "@jupyterlab/builder";
import * as webpack from "webpack";
// Ensure extension assets are available
const themeConfigs = Build.ensureAssets({
output: "./build",
packageNames: ["@my-org/my-extension"],
schemaOutput: "./schemas",
themeOutput: "./themes"
});
// Use custom webpack plugins
const plugins = [
new WPPlugin.FrontEndPlugin("./build", "./static"),
new WPPlugin.JSONLicenseWebpackPlugin()
];
// Create webpack configuration
const compiler = webpack(themeConfigs.concat({
plugins,
// ... other webpack config
}));JupyterLab Builder is built around several key components:
Build namespace): Core functions for asset management and extension metadata handlingWPPlugin namespace): Custom webpack plugins for JupyterLab-specific build tasksThe build system leverages webpack 5's module federation to ensure extensions can be loaded dynamically while sharing common dependencies with the core JupyterLab application.
Core build functionality for managing JupyterLab extension assets, including schema copying, theme processing, and extension metadata normalization.
namespace Build {
function ensureAssets(options: IEnsureOptions): webpack.Configuration[];
function normalizeExtension(module: IModule): ILabExtension;
interface IEnsureOptions {
output: string;
schemaOutput?: string;
themeOutput?: string;
packageNames: ReadonlyArray<string>;
packagePaths?: ReadonlyArray<string>;
}
interface ILabExtension {
readonly extension?: boolean | string;
readonly mimeExtension?: boolean | string;
readonly schemaDir?: string;
readonly themePath?: string;
}
interface IModule {
jupyterlab?: ILabExtension;
main?: string;
name: string;
}
}Custom webpack plugins designed for JupyterLab extension building, including asset copying, license reporting, and build optimization.
namespace WPPlugin {
class FrontEndPlugin {
constructor(buildDir: string, staticDir: string);
apply(compiler: webpack.Compiler): void;
}
class JSONLicenseWebpackPlugin extends LicenseWebpackPlugin {
constructor(pluginOptions?: PluginOptions);
renderLicensesJSON(modules: LicenseIdentifiedModule[]): string;
}
class FilterWatchIgnorePlugin {
constructor(ignored: (path: string) => boolean);
apply(compiler: webpack.Compiler): void;
}
class NowatchDuplicatePackageCheckerPlugin extends DuplicatePackageCheckerPlugin {
constructor(options: DuplicatePackageCheckerPlugin.Options);
apply(compiler: webpack.Compiler): void;
}
const DEFAULT_LICENSE_REPORT_FILENAME: "third-party-licenses.json";
}Automated webpack configuration generation for JupyterLab extensions with module federation, shared dependencies, and asset processing.
interface IOptions {
packagePath?: string;
corePath?: string;
staticUrl?: string;
mode?: 'development' | 'production';
devtool?: string;
watchMode?: boolean;
}
function generateConfig(options?: IOptions): webpack.Configuration[];Command-line tool for building JupyterLab extensions with development and production modes.
build-labextension [options] <extensionPath>