es6-modules

Converting a large Typescript project to ES6 modules

走远了吗. 提交于 2020-01-04 07:25:06
问题 I have a fairly large app (~650 files) that currently has a mixed implementation of ES6 modules and legacy global namespace internal modules and classes. I want to move to 100% ES6 modules. The iterative approach To get there, I need to start by converting all the global objects to ES6 modules by adding the "export" keyword. As soon as I add "export", that global object is no longer global, and each file that uses that object now has a compiler error "object not found"(i.e. Cannot read

Difference between angular 2 modules and Javascript ES6 modules

妖精的绣舞 提交于 2019-12-30 09:46:43
问题 Angular 2 modules allows app to divided into multiple modules each serving a different purpose. But isn't that what ES6 modules also supposed to do? What is the difference between the two? 回答1: Taken from angular.io: The Angular module classes differ from JavaScript module class in three key respects: An Angular module bounds declarable classes only. Declarables are the only classes that matter to the Angular. Instead of defining all member classes in one giant file (as in a JavaScript module

Can I use ES6 modules in Node.js 8? [duplicate]

心已入冬 提交于 2019-12-30 05:59:09
问题 This question already has an answer here : NodeJS plans to support import/export es6 (es2015) modules (1 answer) Closed 2 years ago . Can I use ES6 module syntax with Node.js starting from version 8? Similar questions have already been asked on this site, but answers there are obsolete. I wonder if the situation has changed with new version of Node.js? 回答1: https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c It is in progress but the ETA is 2018 at the

ES6 module Import giving “Uncaught SyntaxError: Unexpected identifier”

倖福魔咒の 提交于 2019-12-27 12:01:32
问题 For a personal project, I'm trying to use ES6 import to write cleaner code. As first test, I'm writing an object that should generate a menu. The whole code is working when I'm directly loading up the class, yet when using the import and export in ES6, it gives an "Uncaught SyntaxError: Unexpected identifier" error on the import line in main.js I've got the following files: assets/js/menu.module.js 'use strict'; export default class Menu { ... } assets/js/main.js import Menu from "./menu

Is it possible to import a .css file using ES6 modules?

折月煮酒 提交于 2019-12-24 15:45:05
问题 I am trying to import a .css file using ES6 modules but I am getting an error. Is it even possible to import a css file without using a bundler or a transpiler (like webpack)? Failed to load module script: The server responded with a non-JavaScript MIME type of "text/css" <html> <body> <div id="app"> {{ msg }} </div> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script type="module"> import './style.css' new Vue({ el: '#app', data: { msg: 'Hello World!' } }) </script>

How do I make jQuery from a ES6 Bundle available to external scripts loaded in the HTML?

偶尔善良 提交于 2019-12-24 09:50:07
问题 On a website, I bundle all the javascript with Gulp into one bundle file. This includes jQuery, which I import into all the JS files that require it. I include the Google Tag Manager (GTM) directly in the HTML. However, some of the custom tags require jQuery, which is undefined according to browser console output. I assume jQuery is not exposed outside the bundle. How do I expose jQuery from the bundle so external scripts such as GTM can use it? 回答1: Solution Got the idea from jqfundamental's

Destructuring assignment within import statements

你离开我真会死。 提交于 2019-12-24 08:25:35
问题 According to this source and a vague memory of having seen this sort of usage in a project somewhere, I'm curious if anyone has been able to do the following: import {map: { series }} from 'contra' As stated on this destructuring assignment overview: The import statement in ES6 behaves similarly to destructuring, but it is important to note that it is not actually destructuring. It appears that imports work a little different and perhaps one cannot expect the same exact behavior, but I haven

Importing node module what exports default class results in a 'module' not a 'constructor'

老子叫甜甜 提交于 2019-12-24 07:34:15
问题 I am trying to import a node module React-Signature-Pad. The index.js file looks like this: import PropTypes from 'prop-types' import React, { Component } from 'react' import trimCanvas from 'trim-canvas' import Bezier from './bezier.js' import Point from './point.js' export default class SignatureCanvas extends Component { static propTypes = { velocityFilterWeight: PropTypes.number, minWidth: PropTypes.number, maxWidth: PropTypes.number, dotSize: PropTypes.oneOfType([PropTypes.number,

Importing node module what exports default class results in a 'module' not a 'constructor'

筅森魡賤 提交于 2019-12-24 07:32:46
问题 I am trying to import a node module React-Signature-Pad. The index.js file looks like this: import PropTypes from 'prop-types' import React, { Component } from 'react' import trimCanvas from 'trim-canvas' import Bezier from './bezier.js' import Point from './point.js' export default class SignatureCanvas extends Component { static propTypes = { velocityFilterWeight: PropTypes.number, minWidth: PropTypes.number, maxWidth: PropTypes.number, dotSize: PropTypes.oneOfType([PropTypes.number,

“Unknown named module” error in react native

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:14:41
问题 I'm creating an app using react native but some imports raise the error from the title: "Unknown named module" . This happens with two packages, react-native-material-design and react-native-db-models , so I suspect the problem isn't on the modules but in my setup. I tried linking the packages with react-native link and repackaging the app using react-native run-android , but none of these solved this issue. I've looked up examples of imports on github, and even copying working code raises