Skip to content

"Convert to ES6 module" not working with IIFE pattern #24297

Closed
@mjbvz

Description

@mjbvz

From @osya on May 21, 2018 8:59

  • VSCode Version: 1.23.1
  • OS Version: Windows 10 Pro x64

Steps to Reproduce:

  1. Create a file test_file.js with the following content:
var path = require('path');

(function () {
    var path = require('path');
}());

scr
Click lightbulb and select "Convert to ES6 module" then the 1st require transforms to the import path from "path";. It is correct. Then comment 1st require and click lightbulb and select "Convert to ES6 module" for the 2nd require. 2nd require doesn't converted to the import path from "path";. ES6 imports must be at the top level of your JavaScript files. So, I suppose, for require in IIFE there should be NO option "Convert to ES6 module"

Copied from original issue: microsoft/vscode#50205

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions