language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

import() function is not allowed (The module could not be parsed: ImportToken)

Open srghma opened this issue 5 years ago • 2 comments

when import webpack function is used

exports.lazyLoadedImport = function() {
  var x = import(
    './Example.Lazy.LazyLoaded.purs'
  )
  console.log(x)
  return x
}

it throws error -

  Unable to parse foreign module:

    examples/lazy/src/LazyLoadedImport.js


    The module could not be parsed:


    ImportToken {tokenSpan = TokenPn 50 2 11, tokenLiteral = "import", tokenComment = [WhiteSpace (TokenPn 49 2 10) " "]}

Expected

import() function should not be parsed as import token

srghma avatar Jul 24 '20 10:07 srghma

@erikd could you suggest how to approach this issue, I would like to make pr


I think this is related to https://github.com/erikd/language-javascript/issues/115

srghma avatar Aug 18 '20 06:08 srghma

For me the best thing would be to just treat it as a global function. My JS bundler then takes care of resolving it.

kim366 avatar Mar 10 '21 10:03 kim366