Add support for dynamic import syntax
pimeo opened this issue · 6 comments
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.
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
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
Sorry, incorrectly closed by a PR.
@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:
- Uninstall the extension that you currently installed
- Install the beta version via
Extensions: Install from VSIX...
command - Completely restart VSCode (quit, and then start the app again)
Thanks for your help 🙇
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.
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!
Done! Please upgrade to 0.3.0 :)