Skip to content

[BUG] packages/d3fc/package.json => scripts => build is broken #1891

Open

Description

@tobiu

inside: https://github.com/d3fc/d3fc/blob/master/packages/d3fc/rollup.config.js

there is:

import babel from '@rollup/plugin-babel';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';

const devMode = process.env.BUILD === 'dev';

let d3fcPkg = require('./package.json');

=> a mixture of ES6 and CommonJS

inside: https://github.com/d3fc/d3fc/blob/master/packages/d3fc/package.json

the rollup plugins are missing, and it probably should include "type": "module"

Activity

  1. defnotjec commented on Apr 15, 2026

    @defnotjec

    This isn't a bug — the build works as intended. A few clarifications:

    Mixed ESM/CJS in rollup config: The require('./package.json') on line 9 is intentional. Rollup's config files support both ESM imports and CJS require() — this is a common pattern for loading JSON in config files that predate import ... assert { type: 'json' }. The ESM imports handle plugins, the CJS require handles the JSON read. Rollup processes the config file itself, so Node's module resolution rules don't apply here.

    Rollup plugins not in packages/d3fc/package.json: This is a Lerna monorepo. Dev dependencies like rollup plugins are hoisted to the root package.json, where they're all present (@rollup/plugin-babel, @rollup/plugin-node-resolve, @rollup/plugin-terser, rollup-plugin-serve, rollup-plugin-livereload). Individual package package.json files only list their runtime dependencies.

    No "type": "module" needed: Rollup handles its own config file module format independently of the package's type field. Adding it would actually risk breaking the require() call and other CJS assumptions in the build tooling.

    npm ci && npm run bundle && npm run bundle-min && npm test all pass cleanly on Node 20.15.0 (the version pinned in CI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions