新提案:import-maps 2.1. "bare" import specifiers 2.2. Import maps 1. ES6 规范 1.1. 导出和导入 1.1.1. 新提案:import-maps 3.1. https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system import-maps : https://github.com/WICG/import-maps Using ES modules in browsers with import-maps: https://blog.logrocket.com
/node_modules/moment/src/moment.js" } } </script> 再引入模块: import moment from "moment"; PS:这种方式被称为import-maps 参考资料 [1] import-maps: https://github.com/WICG/import-maps
还有一个实验功能,称为 import-maps ,看起来效果会更好些。 从1.8.0版本开始,deno中的 import-maps 才是稳定的。
和工具: https://github.com/WICG/import-maps#community-polyfills-and-tooling 参考 https://github.com/WICG/import-maps https://www.honeybadger.io/blog/import-maps/ 如果你有任何想法,欢迎在留言区和我留言,如果这篇文章帮助到了你,欢迎点赞和关注。
</script> 相关文档见:https://github.com/WICG/import-maps 检测是否支持 modules <!
javascript'}); const blobURL = URL.createObjectURL(blob); return blobURL; } // https://github.com/WICG/import-maps
Import 的处理问题,我们的业务代码中直接通过包名导入依赖的方式经过打包工具处理能够正常运行, 如下: import React from 'react' 但是在浏览器中直接运行会直接报错, import-maps pika/cdn-webpack-plugin [7] babel-plugin-macros: https://github.com/kentcdodds/babel-plugin-macros [8] import-maps
第一点是依赖包的数据源问题,简单粗暴点就是创建 manifest 文件,事先预存一份底层通用的依赖包数据,如:Babel 插件相关等,如果需要动态添加依赖包,可以使用 import-maps 特性。
nodejs.org/api/esm.html#esm_import_meta_resolve_specifier_parent [18] 还有一些问题没有定论: https://github.com/WICG/import-maps
好在有一个叫做 import-maps 的提案,该提案主要就是用来解决浏览器无法直接导入模块标识符的问题。但是,在该提案未被完全实现之前,浏览器中依然只能使用 url 进行模块导入。
CSSModules/v1Explainer.md) JSON模块(https://github.com/whatwg/html/pull/4407) 导入地图(https://github.com/WICG/import-maps
Docs: https://deno.land/std/manual.md#import-maps Specification: https://wicg.github.io/import-maps