umd

How to bundle a library with webpack?

强颜欢笑 提交于 2020-07-17 05:19:32
问题 I want to create a frontend library. Therefore I want to use webpack. I especially like the css and image loader. However I can only require non-JS files if I am using webpack. Because I am building a library, I cannot garanty that the user of my library will too. Is there I way to bundle everything into a UMD module to publish it? I tried using multiple entry points, however I cannot require the module then. Thanks in advance 回答1: You can find good guide for creating libraries in Webpack 2.0

How to bundle a library with webpack?

大兔子大兔子 提交于 2020-07-17 05:19:12
问题 I want to create a frontend library. Therefore I want to use webpack. I especially like the css and image loader. However I can only require non-JS files if I am using webpack. Because I am building a library, I cannot garanty that the user of my library will too. Is there I way to bundle everything into a UMD module to publish it? I tried using multiple entry points, however I cannot require the module then. Thanks in advance 回答1: You can find good guide for creating libraries in Webpack 2.0

ES6 modules via script tag has the error “The requested module does not provide an export named 'default' ”

大憨熊 提交于 2020-04-30 09:09:05
问题 I tried to import a module via script tag, <script type="module"> import phonebar from "https://unpkg.com/jssip-emicnet/dist/phonebar.js" I got the error The requested module 'https://unpkg.com/jssip-emicnet/dist/phonebar.js' does not provide an export named 'default' I changed it to so-called "Import a module for its side effects only" and it worked as expected. <script type="module"> import "https://unpkg.com/jssip-emicnet/dist/phonebar.js" MDN said import '/modules/my-module.js'; is to

ES6 modules via script tag has the error “The requested module does not provide an export named 'default' ”

℡╲_俬逩灬. 提交于 2020-04-30 09:08:39
问题 I tried to import a module via script tag, <script type="module"> import phonebar from "https://unpkg.com/jssip-emicnet/dist/phonebar.js" I got the error The requested module 'https://unpkg.com/jssip-emicnet/dist/phonebar.js' does not provide an export named 'default' I changed it to so-called "Import a module for its side effects only" and it worked as expected. <script type="module"> import "https://unpkg.com/jssip-emicnet/dist/phonebar.js" MDN said import '/modules/my-module.js'; is to

UMD和ECMAScript模块

ぐ巨炮叔叔 提交于 2020-03-06 09:30:27
一、UMD:AMD 和CommonJS的糅合 前面花了很长的篇幅介绍了两大类模块规范,CommonJS( Modules / Modules/Wrappings )及 AMD 。 我们知道Modules/Wrappings是出于对Node.js模块格式的偏好而包装下使其在浏览器中得以实现。 而Modules/Wrappings的格式通过某些工具(如 r.js )也能运行在Node.js中。事实上,这两种格式同时有效且都被广泛使用。 AMD以浏览器为第一(browser-first)的原则发展,选择异步加载模块。它的模块支持对象(objects)、函数(functions)、构造器(constructors)、字符串(strings)、JSON等各种类型的模块。因此在浏览器中它非常灵活。 CommonJS module以服务器端为第一(server-first)的原则发展,选择同步加载模块。它的模块是无需包装的(unwrapped modules)且贴近于ES.next/Harmony的模块格式。但它仅支持对象类型(objects)模块。 这迫使一些人又想出另一个更通用格式 UMD (Universal Module Definition)。希望提供一个前后端跨平台的解决方案。 UMD的实现很简单,先判断是否支持Node.js模块格式(exports是否存在),存在则使用Node

Angular 5 - instantiate a component from its name as a string

。_饼干妹妹 提交于 2020-01-30 04:47:11
问题 I know how to init components using ComponentFactoryResolver.resolveComponentFactory(AComponentType) but the method expects a Type , while in my code I have the name of the type as a string . In the Angular API is there a method to resolve by string ? If not, how can I convert a string to a Type in TypeScript? In case that none of the above is possible I will resort to a map but it's not so straightforward as the components I need to instantiate will come from remotely fetched UMD angular