Open Risto-Stevcev opened 1 year ago
Hi @Risto-Stevcev, this is interesting! What's the main use case you see this enabling for a React Native app today?
redirectModulePath
which can achieve the essence of this functionality — redirecting imports to a desired target module.<script type="importmap">
).
externals
in Metro in future. This would allow certain module specifiers to be excluded from bundling, meaning these import
s would be left alone in the resulting bundle — which would then work with import maps implemented by browsers.Note for Metro maintainers: WICG/import-maps is distinct from Package Imports — the latter is considered by runtimes/bundlers interpreting package.json
only and supports private import specifiers with a #
prefix.
Hi @huntie,
I'm really excited about import maps because I think it provides a unique and low-effort way of reusing, securing, or even optimizing code.
For example, say you make a DateTimeRangePicker that uses this DateTimePicker library for React Native. You just implement your standard implementation as usual, using the DateTimePicker for the to/from dates, and validating that the range is acceptable (ie: the to date is earlier than the from date), and ship it. There's a problem though, because what if:
So it's not just react native -- I think this is a low effort way of potentially solving a lot of challenges because import maps allow you to contextualize the imports, effectively allowing you to dependency inject your own implementation of any module without having to fork your own custom copy of the library.
Introduction
Support import maps with react native (see browser support).
Details
With the latest improvements in Node.js and ES6 modules, there 's a new way of developing javascript projects that can avoid a lot of the complexity that often comes with building and setting up a modern javascript project.
The idea is to use import maps with Node.js for your application, so that if you only need vanilla js, you can avoid build steps entirely. The import maps are usually mapped either to
node_modules
as a relative path, or to a url from unpkg/jspm. Note that only npm modules that support ESM work, but there are a lot that do and it will continue to grow.Discussion points
type: module
/.cjs
/.mjs
/await import
).