Skip to content

ECMAScript 6: Modules: import statement with local name is not recognised correctly #32

Open

Description

@svbrunov

Dear Valery Semenchuk (@VISTALL),

Please, kindly see the following issue report.


Environment

Consulo

 Consulo:
  version = 2020.8
  build number = 2599
  build date = August 16, 2020
 Plugins:
  com.intellij = 2599
  <…>
  consulo.javascript = 2894
  <…>

Node

$ node --version
v12.18.3

Problem

The import statements that have the local name specified are not recognised correctly: the Consulo file editor shows the errors with the «Comma expected» message.

ECMAScript 2015 Language Specification

Such import statements are specified by the language specification.
Please, see the table: ECMAScript 2015 Language Specification – ECMA-262 6th Edition: Table 40 (Informative) — Import Forms Mappings to ImportEntry Records:

import {x as v} from "mod";

Test scenario

Precondition steps

  1. Create a new JavaScript project using Consulo: specify the empty directory.

  2. Add the «ECMAScript 6» extension to the project module:

    1. Navigate to the «Project Structure» window (File => Project Structure).
    2. Navigate to the «Modules» tab.
    3. Select the default project module.
    4. Navigate to the «Extensions» tab in the «Modules» tab.
    5. Check the «JavaScript (Client)» item (checkbox) and select the «ECMAScript 6» value in the «Default Version» combobox.
    6. Click the «Apply» button.
    7. Click the «OK» button.
  3. Create the following two .mjs files:

    • a.mjs:
      export function testA() {
          console.log('testA()');
      }
      
    • b.mjs:
      import { testA as localTestA } from './a.mjs';
      
      localTestA();
      
  4. (Optional, but highly recommended.) Run the b.mjs module using node to make sure the module works fine (without errors):

    $ node --experimental-modules b.mjs
    (node:6011) ExperimentalWarning: The ESM module loader is experimental.
    testA()
    

Steps

  1. Open the b.mjs file in Consulo to see (edit) it the Consulo file editor.

Actual result

The Consulo file editor shows two errors with the same «Comma expected» message:
image

Expected result

The Consulo file editor does not show any error.


Best regards,
Sergey Brunov.

Activity

  1. VISTALL commented on Aug 26, 2020

    @VISTALL
    Member

    Hello. Reproduced. I will fix in near future.

    But, do not expect many features from JS plugin. This plugin have minor priority due limited resources.

    Thanks

  2. self-assigned this
    on Aug 26, 2020
  3. added a commit that references this issue on Aug 26, 2020
  4. svbrunov commented on Aug 28, 2020

    @svbrunov
    Author

    Dear Valery Semenchuk (@VISTALL),

    Understood.
    Thank you very much for the prompt reply!

    Best regards,
    Sergey Brunov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions