globalizejs / globalizejs/globalize

Simplify Module IDs in Isomorphic Packages

Open
#672 8 comments 0 reactions 0 assignees View on GitHub
breaking change
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

I have a package that utilizes Globalize.js, and is intended be used in either a CommonJS (Node) or AMD (browser) environment. While it is easy to load everything I need in either environment alone, getting Globalize.js to load correctly in both environments simultaneously is more invovled.

Since the AMD portion of the UMD wrapper references the Cldr.js under the `cldr` package, additional mappings in the loader configuration are needed to redirect `cldr` references back to the `cldrjs` directory so that Node.js doesn't choke when loading the `cldr/unresolved` that's required in browser environments. In this particular instance, the additional mappings would not be necessary if `cldrjs` were used as the package ID instead of `cldr`.

Further, loading the modules underneath `globalize/dist/globalize/` with the IDs `globalize/message`, `globalize/date`, etc. is easy in an AMD environment with the right loader config. Node, on the other hand, cannot resolve those simplified IDs. As such, the full path is needed to resolve those IDs in both Node and the browser (e.g., `require('globalize/dist/globalize/message')`). Using the full paths certainly works, but in the long run it would be ideal to use the simplified IDs that do not reference the directory structure.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.