es6-modules

Does Electron v4 support ECMAScript modules?

隐身守侯 提交于 2019-12-11 03:51:57
问题 I am writing apps using Electron. The current version, 4.0.6, is based on Node 10.11.0 and Chrome 69.0.3947.106. I thought the latest version of Electron would support ECMAScript (ES6) modules but I have not been able to make them work, so far. In particular, on starting the app, the line: import { runTask } from './action'; gives the run-time error: Uncaught SyntaxError: Unexpected token { Before I put more effort into tracking down the problems, I would like to know the status of module

Create ES6 module 'equivalent' using webpack output.target options

邮差的信 提交于 2019-12-10 21:06:07
问题 Firstly, apologies! I struggled summing up the issue in the title so please feel free to amend. The problem Suppose I have two ES6 files that expose default functions // file_1.js export default function(){ /* do the thing */ } // file_2.js export default function(){ /* do the other thing */ } Now I bundle file_1 into a module using webpack (w/ babel loader) using the following output configuration // webpack config 1. { ... entry : '/path/to/file_1.js' output : { path: '/where/it/goes/',

How does javascript import find the module without an extension?

浪尽此生 提交于 2019-12-10 17:38:40
问题 I understand that we can use import {x} from "./file" and a variable x will be imported from file.js in the same directory. How is this handled if there are files of the same name with different extensions in the directory? For example, if there were file.js and file.ts in the same directory, how would import {x} from "./file" behave? Would it depend on the version of javascript? 回答1: Would it depend on the version of javascript? No, it depends on the behavior of javascript runtime, that is,

Typescript compiler is forgetting to add file extensions to ES6 module imports?

左心房为你撑大大i 提交于 2019-12-10 01:54:43
问题 I am trying to compile a Typescript project to JS with ES6 module resolution, but something seems not right. My tsconfig.json looks like this: { "compilerOptions": { "module": "es6", "target": "es6", "sourceMap": true, "lib": ["es6"] } } I build a simple test case with just two modules. The first module ( module1.ts ) just exports a constant: export const testText = "It works!"; The second module ( main.ts ) just imports the export from the first module: import { testText } from 'module1';

Webpack 4 Multi-Part library and sub-libraries

梦想与她 提交于 2019-12-09 19:36:48
问题 Overview I'am developing a javascript library with Webpack4 & ES6 called: "shared-services" which contains different sub-folders. Each of these subfolders represent a "local sub-library" inside which could contain: references to other 3rd libraries like lodash , etc but also references to the methods of the other "sub-folders or sub-libraries" Example I've made an example of my problem and pushed it to github: https://github.com/iarroyo5/multi-part-library-webpack. Helpfully it should be as

webpack imported module is not a constructor

谁说胖子不能爱 提交于 2019-12-09 16:17:46
问题 I created a small JS module which I intend to make an npm package, but for now is just on GitHub. This module is written in ES6 and SCSS, and is thus relying on webpack and babel for transpilation. To test it, I created a separate project with a similar setup (webpack and babel). After npm installing my module, when trying to import it into my index.js, I get the following error in Chrome Developer Tools: (with x being my module's name) index.js:11 Uncaught TypeError: x__WEBPACK_IMPORTED

Use functions defined in ES6 module directly in html

梦想与她 提交于 2019-12-08 19:31:47
问题 I am trying to accomplish a pretty simple thing: I have some code on a javascript module file and I import it on another javascript file (that doesn't export anything) and I want to call some of the defined functions in that file from the HTML directly. Let's se some representative and minimal example of what's happening to me (actually tested the code and gives the exact same issue I'm experiencing with the real one, which is not really much more complex than this one): module.js : const mod

Vue: require a package :cannot assign to read only property 'exports' of object '#<Object>'

不想你离开。 提交于 2019-12-08 12:23:27
问题 I installed package resource-bundle in my project and now to use it in my main.js: /*main.js*/ var co=require('co'); var loader = require('resource-bundle'); co(function*(){ ... ... }).catch(onerror); And this is in the index.js of resource-bundle package: /*index.js*/ module.exports = function*(locale, dir, baseName) { ... ... ... } It gets this error: Cannot assign to read only property 'exports' of object '#<Object>' What's the problem? 回答1: Why your module.exports is a function? It should

Do I need to configure webpack for ES6?

烈酒焚心 提交于 2019-12-08 04:50:47
问题 I have an angular app with a .tsconfig file targeting ES6. { "compileOnSave": false, "compilerOptions": { "allowJs": true, "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "module": "es2015", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2017", "dom", "es2018.promise" ] } } The following angular component (Typescript): import { NgModule } from

Can Rollup & Plugins convert the majority of legacy libraries to es6 modules?

喜欢而已 提交于 2019-12-08 02:27:29
问题 Our team's project is entirely es6 modules (ESM) internally, but has dependencies that have not yet made esm versions. We've created various solutions, but they are definitely not modern, mainstream solutions. By this I mean Rollup workflows which convert legacy formats to esm. Or equivalent. So here's the question: are there now Rollup converters/plugins which can let us bundle all, or at least most, legacy formats into esm? I.e. convert commonJS, iife, umd, amd, (and other) library formats