Skip to content
Anton edited this page Jan 28, 2020 · 3 revisions

There are a few insignificant known issues with Google Closure Compiler.

  1. Cannot do import '.': change to import './'.

    // dot.js
    import test from '.'
    test()
    // index.js
    export default () => {
      console.log('test')
    }
    Show Dot Error
    Exit code 1
    example/bugs/dot.js:2: ERROR - [JSC_JS_MODULE_LOAD_WARNING] Failed to load module "."
    import test from '.'
    ^
    
    1 error(s), 0 warning(s)
    
    
  2. node_modules are not looked up higher than the cwd.

  3. Cannot import json files. Use require.

    import data from './data.json'
    console.log(data)
    Show JSON Error
    Exit code 1
    example/bugs/json.js:1: ERROR - [JSC_CANNOT_PATH_IMPORT_CLOSURE_FILE] Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
    import data from './data.json'
    ^
    
    1 error(s), 0 warning(s)
    
    
  4. Destructuring is broken in Jan 2020 but should be fixed in Feb release.

    (async () => {
      const data = await fetch('https://api.com')
      // should not be renamed
      const { 'hello': hello } = data
      console.log(hello)
    })()
    Show destructuring Error
    'use strict';(async()=>{const a=(await fetch("https://api.com")).a;console.log(a)})();
    

Clone this wiki locally