https://github.com/arlac77/universal-user-agent-bundler-problems
showcase problematic bundling nodes / browser
https://github.com/arlac77/universal-user-agent-bundler-problems
Last synced: about 1 year ago
JSON representation
showcase problematic bundling nodes / browser
- Host: GitHub
- URL: https://github.com/arlac77/universal-user-agent-bundler-problems
- Owner: arlac77
- Created: 2019-09-23T18:37:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-11T23:32:03.000Z (about 4 years ago)
- Last Synced: 2025-03-12T04:35:34.835Z (over 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```sh
node dist/bundeled-with-rollup-cjs-not-working
```
```
/Users/markus/build/universal-user-agent-bundler-problems/dist/bundeled-with-rollup-cjs-not-working:4
return navigator.userAgent;
^
ReferenceError: navigator is not defined
at getUserAgent (/Users/markus/build/universal-user-agent-bundler-problems/dist/bundeled-with-rollup-cjs-not-working:4:5)
at Object. (/Users/markus/build/universal-user-agent-bundler-problems/dist/bundeled-with-rollup-cjs-not-working:7:13)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11
```
```sh
node dist/bundeled-with-rollup-cjs-external-workaround
```
```
Node.js/12.10.0 (macOS Mojave; x64)
```
after patchin with (and rollup rerun)
```
./patch-univeral-user-agent.mjs
```
```sh
node dist/bundeled-with-rollup-cjs-not-working
```
is working fine
```
mbpMarkus:universal-user-agent-bundler-problems markus$ node dist/bundeled-with-rollup-cjs-not-working
Node.js/12.11.1 (macOS Mojave; x64)
```
calling as esm directly without bundler also does not work
```sh
node --experimental-modules index.mjs
```
```
import {Â getUserAgent } from "universal-user-agent";
^^^^^^^^^^^^
SyntaxError: The requested module 'universal-user-agent' does not provide an export named 'getUserAgent'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:93:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:108:20)
at async Loader.import (internal/modules/esm/loader.js:137:24)
```