Skip to content

bug: Does not import browser field from package.json #6335

@Tallyb

Description

@Tallyb

Prerequisites

Stencil Version

4.35.3

Current Behavior

When building with dist output, the built web component of stencil includes the server side code. In this case this is teh qrcode package, which has a package.json as follow:

"main": "./lib/index.js",
  "browser": {
    "./lib/index.js": "./lib/browser.js",
    "fs": false
  },

However, when building stencil components, we need to have the browser code (lib/browser.js) imported and not the server code.
what should be the stencil.config.ts correct configuration to make this happen?

Expected Behavior

import browser side code

System Info

System: node 22.16.0
    Platform: darwin (24.5.0)
   CPU Model: Apple M4 Max (16 cpus)
    Compiler: node_modules/@stencil/core/compiler/stencil.js
       Build: 1751490465
     Stencil: 4.35.3 🎹
  TypeScript: 5.5.4
      Rollup: 4.34.9
      Parse5: 7.2.1
      jQuery: 4.0.0-pre
      Terser: 5.37.0

Steps to Reproduce

use the qrcode package as an example and try to bundle into a component.

Code Reproduction URL

n/a ATM

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions