Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

should import { getter } from 'cjs-mod' work? #517

@dnalborczyk

Description

@dnalborczyk

not sure if this is intended, or a bug.

related to: from #516

I was originally wondering if it should be possible to import promises (which currently is a getter) from fs.

// index.mjs
import { promises as fs } from 'fs'
node --experimental-modules index.mjs
#(node:57314) ExperimentalWarning: The ESM module loader is experimental.
#file:///test/index.mjs:6
#import { promises as fs } from 'fs'
#         ^^^^^^^^
#SyntaxError: The requested module 'fs' does not provide an export named 'promises'
#    at ModuleJob._instantiate (internal/modules/esm/module_job.js:80:21)

node -r esm index.mjs
# file:///test/index.mjs:1

#SyntaxError: Missing export name 'promises' in ES module: fs
#    at file:///test/index.mjs:1

@jdalton after some research I saw your comment that this was planned for node: nodejs/node#20504 (comment) is this still the case and a bug in node and/or esm? or was it decided against to allow named imports of cjs getters?

someone also did mention that it did work prior node v10.2 with esm nodejs/node#20504 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions