Skip to content

Supporting Common JS Named Exports using ES Module Imports #3308

Closed
@zavr-1

Description

@zavr-1

Hello & good day! Since the latest release, the import { version } from './package.json and other imports from JSON files is broken for Node.JS module resolution.

import { version } from '../package.json'
console.log(version)

Version: v20190301 Built on: 2019-03-05 23:14 with

-jar node_modules/google-closure-compiler-java/compiler.jar 
--compilation_level ADVANCED 
--module_resolution NODE
--js t/package.js package.json

produces console.log("0.0.1-alpha");

Whereas the update has now made it not possible :(

Exit code 1                                         
t/package.js:2: ERROR - variable null is undeclared
console.log(version)
            ^^^^^^^

1 error(s), 0 warning(s)

I'm now wondering if importing JSON files is actually part of Ecma6 but I don't see why it shouldn't be for at least for Node Module resolution in Closure.

If works with require and --process_common_js_modules btw:

const { version } = require('../package.json')
console.log(version)

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions