Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Add example of how to use an npm commonjs package like date-fns in ts_devserver & ts_web_test_suite - #343

Merged
gregmagolan merged 2 commits into
angular:masterfrom
gregmagolan:date-fns-browserify-example
Apr 2, 2019
Merged

gregmagolan merged 2 commits into
angular:masterfrom
gregmagolan:date-fns-browserify-example

Conversation

@gregmagolan

@gregmagolan gregmagolan commented Apr 2, 2019 •

Copy link
Copy Markdown
Contributor

This solution works but it requires too much boilerplate code per npm module to scale. Still working on a general solution that scales. See bazel-contrib/rules_nodejs#646.

@gregmagolan
gregmagolan requested a review from alexeagle April 2, 2019 08:05
@gregmagolan

gregmagolan commented Apr 2, 2019 •

Copy link
Copy Markdown
Contributor Author

This works for shallow imports from npm packages such as import {format} from 'date-fns' but it doesn't handle deep imports such as import * as format from 'date-fns/format'. For that you'd need to browserify a separate UMD package that defines the date-fns/format module. It can be done but would result in some duplicate code being loaded if you're using both shallow and deep imports of an npm package.

@alexeagle

Copy link
Copy Markdown
Contributor

Could you add some text here so ppl know this is a temp solution and we plan something more ergonomic for 8?

@gregmagolan
gregmagolan merged commit b70b49c into angular:master Apr 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants