Skip to content

Browser issue when using vite #123

Open
@Sequoia

Description

@Sequoia

Hi,

I'm using your library, it's great! There's an issue with some newer browser bundlers like vite, which don't like something about the colors.js library & blow up when I try to use json-diff.

It looks like the calls to colorize (the only link to colors.js) here and here are a passthrough; the CLI module calls colorize directly (not via the index module).

Would you be amenable to this file being split somehow so the main functionality (the diff function) could be imported from the browser without loading colorize?

Perhaps something like:

- lib/core.js
    - export diff
- lib/index.js
    - import diff from core
    - import colorize etc. from colorize
    - function diffString
    - export {diff, colorize, colorizeCallback, diffString } // preserve existing exports

Then a browser consumer like me could

import { diff } from 'json-diff/core'

and bypass the colorize/colors.js import. I think this would work. Does this sound alright if I can get it working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions