es6-modules

Nested namespaces vs. ES modules

二次信任 提交于 2021-01-29 15:53:09
问题 With traditional JavaScript namespacing techniques I am able to create a nested logical grouping, even over multiple files. How should I replace that with ES modules alias import. Consider the case where I want all my code in a CompanyName namespace, then group by products and within a product I may have a group of shared functions and these could be grouped by topic (very common in many languages like Java, C# etc.). F.e. CompanyName = { ProductName1: { Shared: { Database: {

How to avoid Firebase warning that I’m using the development build?

醉酒当歌 提交于 2021-01-28 06:42:15
问题 I'm making a login page for my ReactJS app using the firebase auth package. I have imported the auth package in my global firebase file: import firebase from 'firebase/app'; import 'firebase/firestore'; import 'firebase/auth'; const config = { apiKey: "xxx", authDomain: "xxx", databaseURL: "xxx", projectId: "xxx", storageBucket: "xxx", messagingSenderId: "xxx" }; export default firebase.initializeApp(config); Now in my LoginComponent I need to access the class FacebookAuthProvider which is

Omit the file extension, ES6 module NodeJS

江枫思渺然 提交于 2021-01-03 07:04:53
问题 I'm trying to get a handle on Node and ES modules. Specifically how/if you can omit the file extension from the path string value of the import statement (and optionally get VSCode to autocomplete those paths). I understand you can either gives files the .mjs extension or set "type" = "modules" in the package.json but both approaches lead to the following problems. VSCode won't autocomplete the path if the file extension is .mjs , it only sees the file if it's .js . However if it is .js the

Omit the file extension, ES6 module NodeJS

删除回忆录丶 提交于 2021-01-03 07:04:25
问题 I'm trying to get a handle on Node and ES modules. Specifically how/if you can omit the file extension from the path string value of the import statement (and optionally get VSCode to autocomplete those paths). I understand you can either gives files the .mjs extension or set "type" = "modules" in the package.json but both approaches lead to the following problems. VSCode won't autocomplete the path if the file extension is .mjs , it only sees the file if it's .js . However if it is .js the

How to use ES6(esm) imports/exports in cloud functions

做~自己de王妃 提交于 2020-12-05 11:56:51
问题 import functions from 'firebase-functions'; import UtilModuler from '@utilModuler' exports.helloWorld = functions.https.onRequest((request, response) => { response.send("Hello from Firebase!"); }); import UtilModuler from '@utilModuler'; ^^^^^^^^^ SyntaxError: Unexpected identifier at Module._compile (internal/modules/cjs/loader.js:721:23) Caveats I'm using third party libraries(@utilModuler) which were written via import/exports. Possible workarounds: Fork library and generate cjs file with

How to include commonjs module in ES6 module node app?

◇◆丶佛笑我妖孽 提交于 2020-12-05 05:01:34
问题 I have a node app that I'd like to use in the standard ES6 module format (i.e., "type": "module" in the package.json, and using import and export throughout) without transpiling down to ES5. But I would like to take advantage of some older libraries such as a express and socket.io that use CommonJS / require format. What are my options (as of 5/2020, Node 12.16.3) for combining CommonJS modules into an ES6 app? 回答1: Working with CommonJS modules is pretty straight forward. You can only do

Using ES6 Modules without a Transpiler/Bundler step

蓝咒 提交于 2020-12-01 10:03:08
问题 I'm interested in using a bunch of JS libraries without depending on npm-based tooling and additional bundling steps. With ES6 modules support in the browser, i can use modules like this: <script type="module"> import Vue from 'https://unpkg.com/vue@2.6.0/dist/vue.esm.browser.min.js'; new Vue({...}); </script> Which is fine when the required module doesn't have any transitive dependencies. But usually, those modules from the transpiled pre-ES6 world do it like this: import Vue from 'vue'