question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nx 9.4.x doesn't use browser entry point properly

See original GitHub issue

Current Behavior

nx 9.4.5 builds React library with node modules, instead of browser modules.

Expected Behavior

As nx 9.3.0 did, build the lib with browser modules.

Steps to Reproduce

I’ve done the exact same thing with both nx 9.4.5 and 9.3.0.

  1. npx create-nx-workspace with React
  2. nx g @nrwl/react:lib mylib --js --publishable
  3. Install uuid and make the appropriate code change

nx 9.4.5

  1. Clone https://github.com/gsong/nx-rollup-problem

  2. npm i

  3. npx nx build mylib

  4. Notice the following errors:

    'crypto' is imported by node_modules/uuid/dist/esm-node/rng.js, but could not be resolved – treating it as an external dependency
    'crypto' is imported by node_modules/uuid/dist/esm-node/md5.js, but could not be resolved – treating it as an external dependency
    'crypto' is imported by node_modules/uuid/dist/esm-node/sha1.js, but could not be resolved – treating it as an external dependency
    

If you look at the dist/libs/mylib/mylib.esm.js, you’ll notice that indeed the module is trying to import crypto:

import crypto from "crypto";

nx 9.3.0

  1. Clone https://github.com/gsong/nx-rollup-problem/tree/nx-9.3
  2. npm i
  3. npx nx build mylib

Success! dist/libs/mylib/mylib.esm.js imports from uuid instead:

import { v4 } from "uuid";

Environment

nx 9.4.5
@nrwl/angular : Not Found
@nrwl/cli : 9.4.5
@nrwl/cypress : 9.4.5
@nrwl/eslint-plugin-nx : 9.4.5
@nrwl/express : Not Found
@nrwl/jest : 9.4.5
@nrwl/linter : 9.4.5
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : 9.4.5
@nrwl/schematics : Not Found
@nrwl/tao : 9.4.5
@nrwl/web : 9.4.5
@nrwl/workspace : 9.4.5
typescript : 3.8.3
nx 9.3.0
@nrwl/angular : Not Found
@nrwl/cli : 9.3.0
@nrwl/cypress : 9.3.0
@nrwl/eslint-plugin-nx : 9.3.0
@nrwl/express : Not Found
@nrwl/jest : 9.3.0
@nrwl/linter : 9.3.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : 9.3.0
@nrwl/schematics : Not Found
@nrwl/tao : 9.3.0
@nrwl/web : 9.3.0
@nrwl/workspace : 9.3.0
typescript : 3.8.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
beemancommented, Mar 25, 2021

@ZackDeRose I had this with the latest and greatest, I’ll create a repro.

0reactions
ZackDeRosecommented, Mar 25, 2021

Appreciate it @beeman!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Different main entry point in package.json for node and browser
json - I don't believe webpack or the browser know or care about package.json for the most part, so you should just set...
Read more >
NX 10 for Engineering Design - MST.edu
2.1 Starting an NX 10 Session and Opening Files . ... 9.4.3 Finishing Profile . ... In a 2D environment, any point has...
Read more >
The Custom executor - GitLab Docs
Below is an example of configuration for the Custom executor using all ... name: my-postgres:9.4 alias: pg entrypoint: ["path", "to", "entrypoint"] command: ...
Read more >
Release Notes for the Cisco ASA Series, 9.14(x)
For secure SNMP polling over a site-to-site VPN, include the IP address of the outside interface in the crypto map access-list as part...
Read more >
Chapter 2. Securing Your Network Red Hat Enterprise Linux 6
Locking GNOME Using gnome-screensaver-command ... 2.8.9.4.1. ... While creating secure passwords is imperative, managing them properly is also important, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found