yorkxin / vscode-coffeescript-support

Advanced CoffeeScript support in VSCode
https://marketplace.visualstudio.com/items?itemName=yorkxin.coffeescript-support
MIT License
29 stars 6 forks source link

Add support for dynamic import syntax #12

Closed pimeo closed 5 years ago

pimeo commented 5 years ago

Hi! As mentionned in the coffeescript changelog, the 2.4.0 brings the possibility to use dynamic import in coffeescript.

But we can see now that there is a error when fill in the following syntax:

module.exports =
    my_components:  import('./my-component.coffee')

Here the following lint error message.

Capture d’écran 2019-04-21 à 18 13 42

I was looking for in your code (and btw exploring the Parser.ts class) to get the line where you detect this kind of error but i wasn't at ease at all to offer you my help. I was supposed before reading your code that linter detection was just about snippets array with some regex and error message in case of it is matched but also that wasn't the case or maybe i'm wrong.. Anyway Could you ignore this error now please and accept import syntaxe without parentheses ?

Thanks a lot.

Reference: https://coffeescript.org/#changelog

yorkxin commented 5 years ago

Hi, thanks for your help. Internally it uses CoffeeScript parser itself. By upgrading the coffeescript package itself, it should be able to parse the new syntax: https://github.com/chitsaou/coffeescript-lsp-core/blob/master/package.json#L18

yorkxin commented 5 years ago

Sorry, incorrectly closed by a PR.

yorkxin commented 5 years ago

@pimeo I've made a beta version that supports import() syntax. Could you give it a try and let me know if that works?

https://github.com/chitsaou/vscode-coffeescript-support/releases/tag/v0.3.0-beta.1

How to test:

  1. Uninstall the extension that you currently installed
  2. Install the beta version via Extensions: Install from VSIX... command
  3. Completely restart VSCode (quit, and then start the app again)

Thanks for your help 🙇

pimeo commented 5 years ago

Tested with the following syntaxes:

# case without parentheses (no dynamic import)
default: -> import "screens/my-screen.coffee"

# case with parentheses (dynamic import)
default: -> import("screens/my-screen.coffee")

# case with parentheses and webpack annotation (dynamic import)
default: -> import(### webpackChunkName: "screens" ### "screens/my-screen.coffee")

@chitsaou you rock! No more error for the dynamic import support. Thanks a lot for your rapidity!

PS: I let you to close the ticket once it is ok for you.

yorkxin commented 5 years ago

Hi @pimeo, sorry for late reply. Thanks for checking. I'll release a new version today, so that you can use that feature without installing the beta version. Happy Hacking!

yorkxin commented 5 years ago

Done! Please upgrade to 0.3.0 :)