ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Resolve Javascript Modules

by Thomas Welter ST3

This plugin for Sublime Text 3 adds completions for es modules, import file paths and browser api's.

Details

  • 1.0.4
  • github.​com
  • github.​com
  • 7 months ago
  • 54 minutes ago
  • 7 months ago

Installs

  • Total 272
  • Win 187
  • Mac 34
  • Linux 51
Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2
Windows 1 2 0 0 1 1 2 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 1 1 1 2 1 4 3 0 2 2 1 0 0 0 0 0
Mac 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0
Linux 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1

Readme

Source
raw.​githubusercontent.​com

Resolve JS Modules

This plugin for Sublime Text 3 adds completions for es modules, import file paths and browser api's.

Auto complete module exports

Auto complete file paths

Auto complete browser api's

How to use

use relative imports: import * as xyz from './relative/path.js' the import path is checked when writing xyz., if the file does not exist or could not be parsed the path is underlined. You can remove any error by fixing the problems and requesting the object again.

How it works

The imports are parsed from the beginning of the file, it looks at wildcard imports of the form import * as xyz from './relative/path.js'. Then the module is parsed using a python port of esprima and cached for later use. The implementation is fully written in python without external dependencies.

Why

There are other plugins available but I find that they have performance problems and bugs. This plugin focuses on performance and javascript specific functionality.

Regenerating browser completions

Open get_browser_completions.html in a browser and copy the console.log to a file browser_completions.json. You can also change the file contents to {} to disable browser completions or add your own there.

limitations

  • nested objects are not completed fully
  • re-exports are ignored
  • parsing is done on the main thread (but is cached)
  • only supports relative paths for imports

esprima

esprima python port is found at: https://github.com/Kronuz/esprima-python esprima itself is found at: https://esprima.org/