kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

kolibri-build 1.1.5: minify with terser-webpack-plugin 5.6.1 and resolve `style-loader` under pnpm

Open rtibblesbot opened this issue 3 weeks ago • 2 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

kolibri-build 1.1.4 has two bugs that projects installing it with pnpm hit, and Kolibri Data Portal carries a workaround for each: prod fails to minify every bundle when terser-webpack-plugin resolves to 5.6.1, and dev --hot cannot resolve style-loader. Both should be fixed and released as kolibri-build 1.1.5.

Complexity: Low Target branch: develop

Context

  • kolibri-build passes terserOptions.output to TerserPlugin.swcMinify (webpack.config.base.js#L137-L146). terser-webpack-plugin 5.6.1, which 1.1.4's ^5.3.16 range allows, adds a format key beside it, and swc treats output as an alias of format, so every bundle fails:

    [ERROR: Kolibri Build] Failed to compile 'kolibri_data_portal.side_nav' bundle!
    kolibri_data_portal.side_nav-26.11.10.1534.js from Terser plugin
    duplicate field `format` at line 1 column 103
    
  • The --hot CSS loader is the bare string 'style-loader' (#L20), while every other loader uses require.resolve. pnpm puts kolibri-build's own style-loader in .pnpm/kolibri-build@…/node_modules/, which resolveLoader.modules does not search (#L165-L175).

  • KDP pins kolibri-build>terser-webpack-plugin to 5.3.16 in pnpm.overrides, and adds a root style-loader devDependency (learningequality/kolibri-data-portal#1247). learningequality/kolibri-data-portal#1244 removes both once the fix ships.

The Change

  • kolibri-build's swc minifier options should work whichever terser-webpack-plugin 5.x the project resolves.
  • The --hot CSS loader should resolve from kolibri-build's own dependencies, like the other loaders.

How to Get There

  1. In a kolibri-data-portal checkout of develop, remove the terser-webpack-plugin override and the root style-loader devDependency, then run pnpm install.
  2. Confirm pnpm-lock.yaml resolves kolibri-build's terser-webpack-plugin to 5.6.1, then run pnpm run build. It fails with duplicate field `format` .
  3. Run kolibri-build dev --plugins <plugin> --hot. It fails with Can't resolve 'style-loader'.

Acceptance Criteria

  • [ ] kolibri-build prod builds KDP with terser-webpack-plugin 5.6.1 and with 5.3.16, and the minified bundles contain no comments.
  • [ ] kolibri-build dev --hot builds a plugin in a pnpm project with no root style-loader.
  • [ ] Non-hot dev builds are unchanged.
  • [ ] packages/kolibri-build/package.json is at 1.1.5.

AI usage

Claude Code (rtibblesbot) hit the minifier failure while working on learningequality/kolibri-data-portal#1234, and Claude Code found the style-loader failure while reviewing a KDP branch. I chose to fix both in one kolibri-build 1.1.5 release, and Claude Code merged the two reports into this task.

rtibblesbot avatar Nov 10 '26 16:11 rtibblesbot

Merged #15812 into this issue: one PR fixes the minifier options and the --hot style-loader resolution, and bumps kolibri-build to 1.1.5.

rtibbles avatar Nov 25 '26 00:11 rtibbles

Plan: kolibri-build minifies under terser-webpack-plugin 5.3.16 and 5.6.1, resolves style-loader itself under --hot, and is versioned 1.1.5.

  • [ ] Minifier options that every terser-webpack-plugin 5.x accepts
  • [ ] --hot CSS loader resolved from kolibri-build
  • [ ] Version 1.1.5, verified against KDP
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • Kolibri's lock moves kolibri-build's terser-webpack-plugin to 5.6.1, so Kolibri's own build and the new spec run on it; if unwanted, the lock hunk and the minifier spec both go (on 5.3.16 the spec passes with output, an empty format or no extractComments), and only the KDP rig covers 5.6.1.
  • The production compile runs in Jest's jsdom environment within an explicit timeout, as the planning session measured (6.7 s); this review could not re-run it (no node_modules in the worktree). If it fails there, the spec goes and the KDP rig plus Task 3's one-plugin Kolibri prod build carry the minifier criterion.
  • Where the session cannot bind a port, compiling the dev --hot config without the dev server is the evidence for the --hot criterion; if a served run is required, that criterion needs a host that allows the bind.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 27 '26 05:11 rtibblesbot