nodejs-logging
nodejs-logging copied to clipboard
es6 import not able to import Logging
I'm trying to use this library on a project now running on node 12 behind --experimental-modules. So this may not be an issue in the future when interoperable named imports are suported - but the exports on this lib seem to differ from other @google-cloud libs that I can "import" via defaults.
Looking at the cjs export the default is v2 and Logging is a named export which I am unable to import without using the cjs require:
import {createRequire} from 'module'; const require = createRequire(import.meta.url);
which lets me revert to const { Logging } = require(..)
Admittedly my understanding of the state of ES6 imports in Node > 12 is very limited - but thought I'd raise this as a potential feature request just to match other libs like pubsub and firebase which I can import via the default cjs export.
EDIT: I'm wrong about the different behaviour... pubsub and datastore both export the same way... it's just firebase admin (that isn't in the @google-cloud family) that exports an ES2015 default.
@rsouthgate ESM requires a complete rewrite of our modules to use native export
functionality. Using createRequire
for the time being I feel is your best bet ... in the future we might offer a separate ESM index, but we're waiting to see what methodologies the community starts adopting.
@bcoe I hope the time is now right for proper ES modules support.
See related request #1287
Closing in favor of the duplicate issue #1287. Thanks!