fullstack-build / tslog

📝 tslog - Universal Logger for TypeScript and JavaScript
https://tslog.js.org
MIT License
1.35k stars 63 forks source link

Bug: "hostname" is not exported by "__vite-browser-external", #254

Closed drewbitt closed 1 year ago

drewbitt commented 1 year ago

Describe the bug Upgrading to 4.8.5 breaks my SvelteKit application when building

RollupError: "hostname" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/tslog@4.8.5/node_modules/tslog/dist/esm/runtime/nodejs/index.js".
    at error (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
    at Module.error (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:13604:16)
    at Module.traceVariable (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:14029:29)
    at ModuleScope.findVariable (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:12547:39)
    at Identifier.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:8267:40)
    at CallExpression.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5850:23)
    at CallExpression.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:9833:15)
    at Property.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5850:23)
    at ObjectExpression.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5846:28)
    at VariableDeclarator.bind (file:///C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5850:23)

To Reproduce Upgrade to 4.8.5 Try to build or run dev a vite project

Expected behavior No error

Additional context Downgrading to 4.8.2 removes the error. Did not try 4.8.3-.4

Node.js Version 20.5.0

OS incl. Version Windows 10

terehov commented 1 year ago

Thank you. There is already a MR for that, I'll release an update in a few min. Sorry about that.

https://github.com/fullstack-build/tslog/pull/253

drewbitt commented 1 year ago

Great! I'd like an issue for the PR in the future so I don't waste time opening an issue, but that's alright :)

terehov commented 1 year ago

Can you try V4.8.6 please? thx

drewbitt commented 1 year ago

I am getting the same error in 4.8.6. RollupError: "hostname" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/tslog@4.8.6/node_modules/tslog/dist/esm/runtime/nodejs/index.js".

Also seeing [plugin:vite:resolve] Module "os" has been externalized for browser compatibility, imported by "C:/Users/andys-pc/GitHub/MyStuff/Someplice/node_modules/.pnpm/tslog@4.8.6/node_modules/tslog/dist/esm/runtime/nodejs/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

There's no reason os should be externalized when it wasn't in 4.8.2

drewbitt commented 1 year ago

Let's re-open this.

BCaspari commented 1 year ago

We also get this issue with 4.8.6, the problem persists...

terehov commented 1 year ago

I agree. What are the exact steps to reproduce it?

drewbitt commented 1 year ago

Reproduction

pnpm create vite-extra tslog-hostname-bug --template ssr-vanilla-ts
cd tslog-hostname-bug
pnpm install
pnpm install tslog
# Add tslog command from README to counter
echo -e "import { Logger, ILogObj } from \"tslog\";\n\nconst log: Logger<ILogObj> = new Logger();\nlog.silly(\"I am a silly log.\");\n$(cat src/counter.ts)" > src/counter.ts
pnpm run build

Errors

terehov commented 1 year ago

Thank you. I found the problem in the package.json I fixed it. Releasing shortly

terehov commented 1 year ago

Can you try v4.8.7 please? thx

drewbitt commented 1 year ago

Resolved in 4.8.7.