Skip to content

[bug] Error on rocket build with a rollup plugin TypeError: Cannot read properties of undefined (reading 'startsWith')  #430

@guillemcordoba

Description

@guillemcordoba

Steps to reproduce:

  1. Run npx @rocket/create@latest, select the documentation theme.
  2. Cd into that folder and run npm install.
  3. Install @rollup/plugin-json with npm i -D @rollup/plugin-json.
  4. Change config/rocket.config.js, adding the rollup json plugin as stated in the documentation:
import json from '@rollup/plugin-json';
import { addPlugin } from 'plugins-manager';

/** @type {import('@rocket/cli').RocketCliOptions} */
export default {
  setupDevServerAndBuildPlugins: [addPlugin(json, { }, { location: 'top' })],
};
  1. Run npm run build.

This is the error that shows up:

guillem@guillem-thinkpad:~/projects/lab/rocket-commonjs-plugin-repro$ npm run build

> [email protected] build
> rocket build

Engine building...
Generating Open Graph Images...
Optimize Production Build...
TypeError: Cannot read properties of undefined (reading 'startsWith')
    at Object.transform (/home/guillem/projects/lab/rocket-commonjs-plugin-repro/node_modules/@web/dev-server-rollup/dist/rollupAdapter.js:228:30)
    at file:///home/guillem/projects/lab/rocket-commonjs-plugin-repro/node_modules/rollup/dist/es/shared/rollup.js:22717:40 {
  code: 'PLUGIN_ERROR',
  plugin: 'json',
  hook: 'transform',
  id: '/home/guillem/projects/lab/rocket-commonjs-plugin-repro/_site-dev/inline-module-ad21fcfbb3d325880e51446273377108.js',
  watchFiles: [
    '/home/guillem/projects/lab/rocket-commonjs-plugin-repro/_site-dev/404.html',

Here is a reproduction repository: https://github.com/guillemcordoba/rocket-commonjs-plugin-repro

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