Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,51 @@ jobs:
ignore_links: 'https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/.* https://mybinder.org/v2/gh/jupyter/notebook/main https://nbviewer.jupyter.org https://stackoverflow.com https://github.com/[^/]+/?$'
ignore_glob: 'ui-tests/test/notebooks/*'

bundle_size:
name: Bundle Size
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: |
python -m pip install -U "jupyterlab>=4.6.0a2,<4.7"
jlpm

- name: Measure bundle sizes
run: |
measure() {
find notebook/static -name "$1" -print0 2>/dev/null | xargs -0 cat 2>/dev/null | wc -c | tr -d ' '
}

jlpm build
DEV_JS=$(measure "*.js")
DEV_MAP=$(measure "*.js.map")

jlpm clean
jlpm build:prod:minimize
MIN_JS=$(measure "*.js")
MIN_MAP=$(measure "*.js.map")

jlpm clean
jlpm build:prod:release
REL_JS=$(measure "*.js")
REL_MAP=$(measure "*.js.map")

fmt() { numfmt --to=iec "$1"; }

{
echo "## Bundle Size Report"
echo ""
echo "| Build | JS Size | Source Maps |"
echo "|-------|---------|-------------|"
echo "| dev | $(fmt $DEV_JS) | $(fmt $DEV_MAP) |"
echo "| prod:minimize | $(fmt $MIN_JS) | $(fmt $MIN_MAP) |"
echo "| prod:release | $(fmt $REL_JS) | $(fmt $REL_MAP) |"
} >> $GITHUB_STEP_SUMMARY

test_lint:
name: Test Lint
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/buildutils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U "jupyterlab>=4.6.0a0,<4.7" hatch
python -m pip install -U "jupyterlab>=4.6.0a2,<4.7" hatch
jlpm
jlpm run build

Expand Down Expand Up @@ -79,6 +79,6 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U "jupyterlab>=4.6.0a0,<4.7" pip
python -m pip install -U "jupyterlab>=4.6.0a2,<4.7" pip
jlpm
jlpm run build
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"build": "rspack",
"build:prod": "rspack --config ./rspack.prod.config.js",
"build:prod:minimize": "rspack --config ./rspack.prod.minimize.config.js",
"build:prod:release": "rspack --config ./rspack.prod.release.config.js",
"clean": "rimraf build && jlpm run clean:static",
"clean:static": "rimraf -g \"../notebook/static/!(favicons)\"",
"watch": "rspack --watch --config rspack.config.js"
Expand Down
29 changes: 29 additions & 0 deletions app/rspack.prod.minimize.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

const merge = require('webpack-merge').default;
const WPPlugin = require('@jupyterlab/builder').WPPlugin;
const config = require('./rspack.config');

config[0] = merge(config[0], {
mode: 'production',
devtool: 'source-map',
output: {
// Add version argument when in production so the Jupyter server
// allows caching of files (i.e., does not set the CacheControl header to no-cache to prevent caching static files)
filename: '[name].[contenthash].js?v=[contenthash]',
},
optimization: {
minimize: true,
},
plugins: [
new WPPlugin.JSONLicenseWebpackPlugin({
excludedPackageTest: (packageName) =>
packageName === '@jupyter-notebook/app',
}),
],
});

module.exports = config;
14 changes: 14 additions & 0 deletions app/rspack.prod.release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

const merge = require('webpack-merge').default;
const config = require('./rspack.prod.minimize.config');

config[0] = merge(config[0], {
// Turn off source maps
devtool: false,
});
Comment on lines +6 to +12
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rspack.prod.release.config.js imports ./rspack.prod.minimize.config and then mutates config[0]. Because Node caches require() results, this also mutates the exported config from rspack.prod.minimize.config.js within the same process, which can lead to surprising behavior if both configs are ever loaded in one run (e.g., tooling/tests). Consider building the release config directly from ./rspack.config (or deep-cloning the minimize config) instead of requiring-and-mutating another config module.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These config files are not meant to be used simultaneously.


module.exports = config;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"build": "lerna run build",
"build:lib": "lerna run build:lib",
"build:prod": "lerna run build:prod --skip-nx-cache",
"build:prod:minimize": "lerna run build:prod --skip-nx-cache --ignore @jupyter-notebook/app && jlpm workspace @jupyter-notebook/app build:prod:minimize",
"build:prod:release": "lerna run build:prod --skip-nx-cache --ignore @jupyter-notebook/app && jlpm workspace @jupyter-notebook/app build:prod:release",
"build:test": "lerna run build:test",
"build:utils": "cd buildutils && npm run build",
"clean": "lerna run clean",
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ ensured-targets = [
install-pre-commit-hook = true

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
build_cmd = "build:prod:release"
source_dir = "packages"
build_dir = "notebook/static"
npm = ["jlpm"]
Expand All @@ -188,7 +188,7 @@ before-bump-version = [
]
before-build-npm = [
"jlpm clean",
"jlpm build:prod"
"jlpm build:prod:release"
]
before-build-python = [
"jlpm clean"
Expand Down
Loading