babeljs

Typescript/babel import causing “_1.default is not a function”

心已入冬 提交于 2021-02-20 18:46:58
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

Typescript/babel import causing “_1.default is not a function”

旧巷老猫 提交于 2021-02-20 18:46:55
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

How to make AudioWorklets work with vue-cli/webpack/babel? (getting illegal invocation error)

半腔热情 提交于 2021-02-19 05:18:46
问题 I'm trying to create a WebApp with vue-cli that uses AudioWorklets, but I'm getting a bunch of errors when trying to access any property of my AudioWorkletNode, like port or channelCount etc: TypeError: Illegal invocation at MyWorkletNode.invokeGetter After hours of googling and debugging I think it's somehow related to classes, AudioWorklet seems to only work with ES6 classes but one of vue-cli/babel/webpack does it's magic (which I don't understand where and what it does) and transpiles the

Webpack + Babel Wrong Line Numbers in Stack Trace

穿精又带淫゛_ 提交于 2021-02-19 02:42:25
问题 I'm building an application with Webpack and Babel. When the application runs into an error, it correctly lists the line number for the first error but then shows the line number for the minified code for each subsequent step. My Webpack config is as follows, const webpack = require('webpack'); const path = require('path'); module.exports = { module: { loaders: [ { loader: "babel-loader", exclude: [ /(node_modules)/, ], query: { presets: ['es2015','react'], plugins: ['transform-object-rest

Why do I have to put async keyword to functions which have await keywords?

浪尽此生 提交于 2021-02-18 22:33:06
问题 I just want to wait for a process to finish, not want to make the function asynchronous. See the below code. I had to make getUserList asynchronous because there was an await keyword in the function. Therefore I also had to write like "await UsersService.getUserList" to execute the method and also I had to make the parent function asynchronous. That's not what I want to do. import xr from 'xr' //a package for http requests class UsersService { static async getUserList() { const res = await xr

Why do I have to put async keyword to functions which have await keywords?

风流意气都作罢 提交于 2021-02-18 22:30:27
问题 I just want to wait for a process to finish, not want to make the function asynchronous. See the below code. I had to make getUserList asynchronous because there was an await keyword in the function. Therefore I also had to write like "await UsersService.getUserList" to execute the method and also I had to make the parent function asynchronous. That's not what I want to do. import xr from 'xr' //a package for http requests class UsersService { static async getUserList() { const res = await xr

Is it possible to use both “require” and “import” together with Webpack?

我们两清 提交于 2021-02-17 02:45:48
问题 We had to update some dependencies to switch to Webpack 4 and are getting a warning in webpack and an error in the browser when trying to mix import and require within the same project. We have a very large project (300+ files) with some files using var Pkg = require('./fileName'); and module.exports = MyComponent while others use import Pkg from './fileName' and export default MyComponent and would prefer to not have to go through each one using require/module.exports and update them.

Is it possible to use both “require” and “import” together with Webpack?

懵懂的女人 提交于 2021-02-17 02:45:11
问题 We had to update some dependencies to switch to Webpack 4 and are getting a warning in webpack and an error in the browser when trying to mix import and require within the same project. We have a very large project (300+ files) with some files using var Pkg = require('./fileName'); and module.exports = MyComponent while others use import Pkg from './fileName' and export default MyComponent and would prefer to not have to go through each one using require/module.exports and update them.

Dynamic JSX element/tag names

时间秒杀一切 提交于 2021-02-16 13:39:10
问题 I'm just wanted to know if there is a best practice approach to rendering an element with ReactJS dynamically Consider these scenarios: (1) Parameter Factory component: A parameterised factory component whose job is to render a component based on a string parameter , is there a way of doing so without having to revert to React.createElement? <pre><code>// The following doesn't work class Quiz extends React.Component{ constructor (props){ super (props); this.state = { questionText: '',

Dynamic JSX element/tag names

*爱你&永不变心* 提交于 2021-02-16 13:39:08
问题 I'm just wanted to know if there is a best practice approach to rendering an element with ReactJS dynamically Consider these scenarios: (1) Parameter Factory component: A parameterised factory component whose job is to render a component based on a string parameter , is there a way of doing so without having to revert to React.createElement? <pre><code>// The following doesn't work class Quiz extends React.Component{ constructor (props){ super (props); this.state = { questionText: '',