vfile/vfile-reporter

One of dep requires node API, that breaks the browser build

linonetwo opened this issue · 5 comments

Initial checklist

Affected packages and versions

"vfile-reporter": "^7.0.2"

Link to runnable example

https://github.com/linonetwo/template-based-generator-template/tree/84fa27aa65db3fd10af140aa5cc7a9a815a0f326

Steps to reproduce

visit demo/useTemplateGeneration.ts , uncomment vfile-reporter, and run npm run dev:demo

You can see error caused by node API in the browser.

Expected behavior

No node api when using in the browser.

Actual behavior

(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
process (imported by node_modules/vfile-reporter/node_modules/supports-color/index.js, node_modules/vfile-reporter/node_modules/has-flag/index.js)
tty (imported by node_modules/vfile-reporter/node_modules/supports-color/index.js)
os (imported by node_modules/vfile-reporter/node_modules/supports-color/index.js)
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
process (guessing 'process$2')
os (guessing 'os')
tty (guessing 'tty')

Runtime

Node v16

Package manager

npm v7

OS

macOS

Build and bundle tools

Rollup

I’m open to accepting a PR that uses a browser field similar to how unist-util-inspect does some of this: https://github.com/syntax-tree/unist-util-inspect/blob/d56810089d0ae71b65917256002e6094e9dd6eaa/package.json#L29-L34.
But then using supports-color in the normal/Node.js version.

Can you work on that?

Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.

Is this something you can and want to work on?

Team: please use the area/* (to describe the scope of the change), platform/* (if this is related to a specific one), and semver/* and type/* labels to annotate this. If this is first-timers friendly, add good first issue and if this could use help, add help wanted.

Ok, I can try this, just after I finish my hackathon project!

Looks like a simple first issue.

@linonetwo friendly ping, is this still something you're interested in?

Wow, barely forget, will try this today.