Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion js/jscompiler.vim
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ endfunction

function s:JavascriptCompiler.compile_unlet(node)
let list = map(a:node.list, 'self.compile(v:val)')
call self.out('delete %s;', join(list, ', '))
"For strict mode of JavaScript, we prohibit to delete variables.
"call self.out('delete %s;', join(list, ', '))
call self.out('%s;', join(list, ', '))
endfunction

function s:JavascriptCompiler.compile_lockvar(node)
Expand Down Expand Up @@ -864,6 +866,11 @@ function! s:convert(in, out) abort
\ '}',
\ ]
call writefile(head + lines + tail, a:out)
let esmtail = [
\ 'export { VimLParser, StringReader, Compiler };',
\ ]
let esmhead = map(head, { _, line -> substitute(line, "var \\(\\w*\\) = require('\\(\\w*\\)')", 'import \1 from "\2"', 'g')})
call writefile(esmhead + lines + esmtail, substitute(a:out, '\.js', '\.mjs', ''))
catch
throw substitute(v:throwpoint, '\.\.\zs\d\+', '\=s:numtoname(submatch(0))', 'g') . "\n" . v:exception
endtry
Expand Down
Loading