es6-modules

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

How do you get webpack to *actually* ignore an external and rely on the browser to import?

百般思念 提交于 2020-04-16 03:11:11
问题 I'm trying to get webpack to ignore an import, so that its imported by the browser using a native ES6 import statement, not webpack. I'm trying to get ffmpeg.js to import directly as it crashes webpack when it tries to bundle it, as the files are too large. Following the answer here (How to exclude a module from webpack, and instead import it using es6), I have my code in the local tree as /ffmpeg/ffmpeg-mpeg.js and verified my dev server can access as http://localhost:8080/ffmpeg/ffmpeg-webm

How to exclude a module from webpack, and instead import it using es6

对着背影说爱祢 提交于 2020-04-14 06:13:30
问题 I am currently using webpack to bundle up a javascript file with react. This file also has another import statement to another module within my project import { MyModule} from './MyModuleFile.js' Is there a way to exclude MyModule.js from the webpack bundle, and instead keep the import as is? 回答1: What you're after is the externals option in your webpack.config.js module.exports = { //... externals: { './MyModuleFile': 'MyModule', } }; 回答2: Just add it to the exclude option in your loader

How to integrate ES6 Module syntax in RequireJS project

允我心安 提交于 2020-04-11 02:07:13
问题 I'm looking for a way to use ES6 Modules (import/export) syntax in my current RequireJS project. I can run my project directly in a recent browser, without build or Babel transformation. I build my project with r.js and Babel only for production. We would like to start building ES6 modules and use it with requireJS. Is there a way to do that ? NB : RequireJS does not load dependencies written in ES6. 回答1: Yes, RequireJS should be compatible with Babel's es2015-modules-umd plugin. So you

How to integrate ES6 Module syntax in RequireJS project

故事扮演 提交于 2020-04-11 02:06:50
问题 I'm looking for a way to use ES6 Modules (import/export) syntax in my current RequireJS project. I can run my project directly in a recent browser, without build or Babel transformation. I build my project with r.js and Babel only for production. We would like to start building ES6 modules and use it with requireJS. Is there a way to do that ? NB : RequireJS does not load dependencies written in ES6. 回答1: Yes, RequireJS should be compatible with Babel's es2015-modules-umd plugin. So you

How load an emscripten generated module with es6 import?

自闭症网瘾萝莉.ら 提交于 2020-03-23 07:59:49
问题 I am trying to import a module generated with emscripten as a es6 module. I am trying with the basic example from emscripten doc. This is the command I am using to generate the js module from the C module: emcc example.cpp -o example.js -s EXPORTED_FUNCTIONS="['_int_sqrt']" -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" -s EXPORT_ES6=1 -s MODULARIZE=1 The C module : #include <math.h> extern "C" { int int_sqrt(int x) { return sqrt(x); } } Then importing the generated js module: <

How to use redux-thunk from node server side?

微笑、不失礼 提交于 2020-03-21 07:00:18
问题 (code from https://redux.js.org/advanced/async-actions) The code setups a redux store and then calls dispatch on the store with some actions. The store use redux-thunk to manage async API calls. Here is the index.js import reduxThunk from 'redux-thunk' const { thunkMiddleware } = reduxThunk; import redux from 'redux'; const { createStore } = redux; const { applyMiddleware } = redux; import { selectSubreddit, fetchPosts } from './actions.js' import rootReducer from './reducers.js' const store

Why and when to use default export over named exports in es6 Modules?

本秂侑毒 提交于 2020-03-13 04:25:16
问题 I have referred all the questions in stackoverflow. But none of the suggested why and when to use default export. I just saw that default can be metioned "When there is only one export in a file" Any other reason for using default export in es6 modules? 回答1: Some differences that might make you choose one over the other: Named Exports Can export multiple values MUST use the exported name when importing Default Exports Export a single value Can use any name when importing This article does a

Why and when to use default export over named exports in es6 Modules?

冷暖自知 提交于 2020-03-13 04:24:51
问题 I have referred all the questions in stackoverflow. But none of the suggested why and when to use default export. I just saw that default can be metioned "When there is only one export in a file" Any other reason for using default export in es6 modules? 回答1: Some differences that might make you choose one over the other: Named Exports Can export multiple values MUST use the exported name when importing Default Exports Export a single value Can use any name when importing This article does a