Skip to content

Shipped browser builds embed Node core built-ins (node:fs, node:process), so neither <script> nor <script type="module"> loads in a browser #118

Description

@jeanmachuca

Summary

The QCObjects builds shipped in the current npm package (qcobjects@2.5.142) do not load in a plain browser. Loading the framework via a classic <script> tag — the method documented in the official ReadTheDocs/README "straight way into HTML5" guides — throws at load time, so CONFIG, Class, New, Component, etc. are never defined and the app does nothing. The ESM build also fails to initialize.

Additionally, the qcobjectsnewapp (2.4) quick-start template scaffolded with qcobjects-cli create <app> --pwa no longer builds or tests against the current qcobjects runtime.

Environment

  • qcobjects@2.5.142 (latest) installed via npm
  • qcobjectsnewapp@2.4.40-ts template (what qcobjects-cli create --pwa scaffolds)
  • Node v24.18.1, npm 11.12.1
  • Chromium headless (headless=new) for browser verification

Repro 1 — classic <script> fails to load any shipped browser bundle

Create a minimal page that loads the framework exactly as the docs show:

<!DOCTYPE html>
<html>
  <head><title>demo</title></head>
  <body>
    <script type="text/javascript" src="js/QCObjects.js"></script>
    <script type="text/javascript">
      console.log(typeof CONFIG);
    </script>
  </body>
</html>

Point js/QCObjects.js at each build present in the package and observe in a browser console:

File Result
public/browser/QCObjects.js Uncaught Error: Dynamic require of "node:process" is not supported
build/QCObjects.js (2.4 TS CommonJS) Uncaught ReferenceError: exports is not defined
public/esm/index.mjs (via <script type="module">) module import hangs/never initializes; importing module body never runs

In every case CONFIG is undefined and nothing executes.

Repro 2 — the scaffolded app does not build or test

Using the official CLI:

npm i -g qcobjects-cli
qcobjects create mynewapp --pwa
cd mynewapp
npm test          # eslint passes; jasmine fails (expects 2.4-era globals: logger, __definition, _sdk_)
npx tsc --noEmit  # TS2305 errors: qcobjects has no exported member 'CONFIG', 'Component', 'Package', ...
npm run publish:web # crashes at the first step (publish:static exits 1 with no output)

The template's TypeScript source targets 2.4-era globals/exports that no longer exist in the qcobjects@2.5.x types installed as its dependency.

Expected behavior

  • One of the shipped builds should load via a plain <script> tag (as the docs describe) and expose the global framework API (CONFIG, Class, New, Component, Import, ...).
  • The official qcobjectsnewapp template should build (npm run publish:web) and pass its own tests (npm test) with the version of qcobjects it declares as a dependency.

Notes

  • The CDN build at https://qcobjects.dev/QCObjects.js is the one documented to work, but that exact browser build is not what gets installed from npm — the npm package's own browser/ESM/2.4 builds all fail in a browser here.
  • The browser/QCObjects.js bundle (esbuild) references node:process, i.e. Node built-ins leaked into the browser bundle.

Impact

Any project scaffolded from the official template, or following the docs' "no transpiler, pure JavaScript" guidance with the npm package, does not run out of the box.

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