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.

Node browser resolution strategy

See original GitHub issue

I’d like to propose a new resolution strategy that builds upon node resolution to support https://github.com/defunctzombie/package-browser-field-spec - node+browser. The core differences is that it reads package.json/browser to select the entry point or module “aliases”. For example, browser can point to a string that is used in place of main when resolving or specific a map of keys to values - where the key is a relative path or a module name and the value is a boolean, relative path or module name.

This module resolution is used in Browserify by default, and can be enabled in Webpack using https://webpack.github.io/docs/configuration.html#resolve-packagealias. It’s the primary way to develop and distribute universal packages that work on node and in browsers.

Edit: It would also be amazing to have the compiler handle this when developing packages so that the aliases are type-checked to be compatible in both environments. For example, it could catch https://github.com/blakeembrey/popsicle/pull/47.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:15
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
PatrickJScommented, Nov 16, 2016

This is also a problem for Angular’s use of Ahead of Time compiler which uses TypeScript’s extensibility feature. When splitting code per platform there must be two paths created

angular2-universal/browser angular2-universal/node

https://github.com/angular/universal-starter/blob/master/src/app/app.browser.module.ts#L3

1reaction
daprahamiancommented, Jun 30, 2017

👍 for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Module Resolution - TypeScript
Node. This resolution strategy attempts to mimic the Node.js module resolution mechanism at runtime. The full Node.js resolution algorithm is outlined in Node....
Read more >
Understanding JavaScript Module Resolution Systems with ...
Learn the difference between the common module resolution systems with code examples and help from our prehistoric friends.
Read more >
Module Resolution Strategy | TypeScript Tutorial - YouTube
Access 7000+ courses for 60 days FREE: https://pluralsight.pxf.io/c/1291657/424552/7490 "How does TypeScript compiler find a module?
Read more >
how to get the browser's screen resolution in the server end?
You can't get the screen resolution on the server side, you'll have to get it on the client side and pass it back...
Read more >
Change desktop screen resolution in Selenium tests
Change desktop screen resolution for Selenium tests using the resolution ... In this guide, you will learn: ... Java; Node.js; C#; PHP; Python;...
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