frankwallis / plugin-typescript

TypeScript loader for SystemJS
MIT License
248 stars 47 forks source link

typescript_1["default"].ModuleKind - " Cannot read property MuduleKind of undefined" #189

Closed josh-sachs closed 7 years ago

josh-sachs commented 7 years ago

plugin.js line 93 is throwing this error.

Cannot read property 'ModuleKind' of undefined TypeError: Cannot read property 'ModuleKind' of undefined at parseConfig.

line 93: result.module = getEnum(result.module, typescript_1["default"].ModuleKind, typescript_1["default"].ModuleKind.System);

trying to understand why typescript_1["default"] is undefined.

{ warnings: true,
  map: 
   { app: 'app',
     aot: 'aot',
     '@angular': 'lib:@angular',
     rxjs: 'lib:rxjs',
     'reflect-metadata': 'lib:reflect-metadata',
     '@ngrx/core': 'lib:@ngrx/core',
     '@ngrx/store': 'lib:@ngrx/store',
     localforage: 'lib:localforage',
     moment: 'lib:moment',
     underscore: 'lib:underscore',
     hammerjs: 'lib:hammerjs',
     jquery: 'lib:jquery',
     'jquery.mCustomScrollbar': 'lib:jquery/plugins',
     'jquery.jquery-mousewheel': 'lib:jquery/plugins',
     'jquery.select2': 'lib:jquery/plugins',
     'jquery.autosize': 'lib:jquery.autosize',
     swiper: 'lib:swiper',
     clndr: 'lib:clndr',
     'materialize-css': 'lib:materialize-css',
     noUiSlider: 'materialize-css/extras/noUiSlider',
     clipboard: 'lib:clipboard',
     sortablejs: 'lib:sortablejs',
     wnumb: 'lib:wnumb',
     typescript: 'lib:typescript',
     'plugin-typescript': 'lib:typescript' },
  meta: {},
  paths: { 'lib:': 'lib/' },
  packages: 
   { '@angular/http': { main: 'index.js', defaultExtension: 'js' },
     '@angular/core': { main: 'index.js', defaultExtension: 'js' },
     '@angular/router': { main: 'index.js', defaultExtension: 'js' },
     '@angular/common': { main: 'index.js', defaultExtension: 'js' },
     '@angular/compiler': { main: 'index.js', defaultExtension: 'js' },
     '@angular/forms': { main: 'index.js', defaultExtension: 'js' },
     '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' },
     '@angular/platform-webworker': { main: 'index.js', defaultExtension: 'js' },
     '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' },
     '@angular/platform-webworker-dynamic': { main: 'index.js', defaultExtension: 'js' },
     rxjs: 
      { main: undefined,
        defaultExtension: 'ts',
        format: undefined,
        meta: [Object] },
     aot: 
      { main: undefined,
        defaultExtension: 'ts',
        format: undefined,
        meta: [Object] },
     app: 
      { main: undefined,
        defaultExtension: 'ts',
        format: undefined,
        meta: [Object] },
     'reflect-metadata': 
      { main: 'reflect',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     '@ngrx/core': 
      { main: 'index',
        defaultExtension: 'js',
        format: undefined,
        meta: {} },
     '@ngrx/store': 
      { main: 'index',
        defaultExtension: 'js',
        format: undefined,
        meta: {} },
     localforage: 
      { main: 'localforage',
        defaultExtension: 'js',
        format: undefined,
        meta: {} },
     moment: 
      { main: undefined,
        defaultExtension: [Object],
        format: undefined,
        meta: {} },
     underscore: 
      { main: undefined,
        defaultExtension: [Object],
        format: undefined,
        meta: {} },
     hammerjs: 
      { main: 'hammer',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     jquery: 
      { main: 'jquery',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     'jquery.mCustomScrollbar': 
      { main: 'jquery.mCustomScrollbar',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     'jquery.jquery-mousewheel': 
      { main: 'jquery.mousewheel',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     'jquery.select2': 
      { main: 'select2.full',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     'jquery.autosize': 
      { main: undefined,
        defaultExtension: [Object],
        format: undefined,
        meta: {} },
     swiper: 
      { main: 'swiper',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     clndr: 
      { main: 'clndr',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     'materialize-css': 
      { main: 'materialize',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     noUiSlider: 
      { main: 'noUiSlider',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     clipboard: 
      { main: 'clipboard',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     sortablejs: 
      { main: 'sortable',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     wnumb: 
      { main: 'wnumb',
        defaultExtension: 'js',
        format: 'global',
        meta: {} },
     typescript: { main: 'typescript.js', meta: { exports: 'ts' } },
     'plugin-typescript': { main: 'plugin.js' } },
  typescriptOptions: 
   { target: 'es5',
     module: 'es2015',
     emitDecoratorMetadata: true,
     experimentalDecorators: true },
  transpiler: 'plugin-typescript' }
frankwallis commented 7 years ago

If you are using systemjs 0.19 then I think you need to stick with plugin-typescript 5.x.x

josh-sachs commented 7 years ago

I tried with 6.0.4 and 5.3.3 - I think I had this working at one point. I'm trying to understand where that reference to typescript_1["default"] is set as it must be missing from my configuration some how.

frankwallis commented 7 years ago

I think this is happening inside the plugin itself and is related to https://github.com/frankwallis/plugin-typescript/issues/185

guillaume86 commented 7 years ago

I have a very similar error:

Uncaught (in promise) Error: Cannot read property 'System' of undefined

in the plugin code:

this._options.module = this.getEnum(this._options.module, typescript_1.ModuleKind, typescript_1.ModuleKind.System);

This error occured after trying to update typescript and typescript-plugin.

Unfortunately I didn't manage to rollback to a working state even after restoring project with git + deleting jspm_packages and node_modules and running the install again. Any help is welcome.

EDIT: ok I solved it by pinning the jspm version: https://github.com/piotrwitek/react-redux-typescript-starter-kit/issues/38

josh-sachs commented 7 years ago

I got this working again, but no idea how. this works with plugin-typescript 5 and 6 against systemjs 19.

Here is my working systemjs.config.js file for posterity.

{  
   "warnings":true,
   "map":{  
      "@angular":"lib:@angular",
      "aot":"aot",
      "app":"app",
      "rxjs":"lib:rxjs/",
      "@ngrx/core":"lib:@ngrx/core/",
      "@ngrx/store":"lib:@ngrx/store/",
      "reflect-metadata":"lib:reflect-metadata/",
      "moment":"lib:moment/",
      "underscore":"lib:underscore/",
      "underscore.string":"lib:underscore/string",
      "sortablejs":"lib:sortablejs/",
      "clndr":"lib:clndr/",
      "swiper":"lib:swiper/",
      "select2":"lib:select2/",
      "autosize":"lib:autosize/",
      "jquery":"lib:jquery/",
      "jquery.mousewheel":"lib:jquery.mousewheel/",
      "jquery.mCustomScrollbar":"lib:jquery.mCustomScrollbar/",
      "hammerjs":"lib:hammerjs/",
      "localforage":"lib:localforage/",
      "wnumb":"lib:wnumb/",
      "clipboard":"lib:clipboard/",
      "materialize-css":"lib:materialize-css/dist/js",
      "noUiSlider":"lib:materialize-css",
      "plugin-babel":"lib:babel/plugin-babel.js",
      "systemjs-babel-build":"lib:babel/systemjs-babel-browser.js",
      "plugin-typescript":"lib:typescript",
      "typescript":"lib:typescript"
   },
   "meta":{  

   },
   "paths":{  
      "lib:":"lib/"
   },
   "packages":{  
      "@angular/http":{  
         "main":"/bundles/http.umd.js",
         "defaultExtension":"js"
      },
      "@angular/core":{  
         "main":"/bundles/core.umd.js",
         "defaultExtension":"js"
      },
      "@angular/router":{  
         "main":"/bundles/router.umd.js",
         "defaultExtension":"js"
      },
      "@angular/common":{  
         "main":"/bundles/common.umd.js",
         "defaultExtension":"js"
      },
      "@angular/compiler":{  
         "main":"/bundles/compiler.umd.js",
         "defaultExtension":"js"
      },
      "@angular/forms":{  
         "main":"/bundles/forms.umd.js",
         "defaultExtension":"js"
      },
      "@angular/platform-browser":{  
         "main":"/bundles/platform-browser.umd.js",
         "defaultExtension":"js"
      },
      "@angular/platform-webworker":{  
         "main":"/bundles/platform-webworker.umd.js",
         "defaultExtension":"js"
      },
      "@angular/platform-browser-dynamic":{  
         "main":"/bundles/platform-browser-dynamic.umd.js",
         "defaultExtension":"js"
      },
      "@angular/platform-webworker-dynamic":{  
         "main":"/bundles/platform-webworker-dynamic.umd.js",
         "defaultExtension":"js"
      },
      "aot":{  
         "defaultExtension":"ts"
      },
      "app":{  
         "defaultExtension":"ts"
      },
      "rxjs":{  
         "defaultExtension":"ts"
      },
      "@ngrx/core":{  
         "defaultExtension":"js",
         "main":"index",
         "format":"esm",
         "meta":{  
            "*.js":{  
               "loader":"plugin-babel"
            }
         }
      },
      "@ngrx/store":{  
         "defaultExtension":"js",
         "main":"index",
         "format":"esm",
         "meta":{  
            "*.js":{  
               "loader":"plugin-babel"
            }
         }
      },
      "reflect-metadata":{  
         "defaultExtension":"js",
         "main":"reflect",
         "format":"global"
      },
      "moment":{  
         "defaultExtension":"js",
         "main":"moment",
         "format":"global"
      },
      "underscore":{  
         "defaultExtension":"js",
         "main":"underscore",
         "format":"global"
      },
      "underscore.string":{  
         "defaultExtension":"js",
         "main":"underscore.string",
         "format":"global"
      },
      "sortablejs":{  
         "defaultExtension":"js",
         "main":"sortable",
         "format":"global"
      },
      "clndr":{  
         "defaultExtension":"js",
         "main":"clndr",
         "format":"global"
      },
      "swiper":{  
         "defaultExtension":"js",
         "main":"swiper",
         "format":"global"
      },
      "select2":{  
         "defaultExtension":"js",
         "main":"select2.full",
         "format":"global"
      },
      "autosize":{  
         "defaultExtension":"js",
         "main":"autosize",
         "format":"global"
      },
      "jquery":{  
         "defaultExtension":"js",
         "main":"jquery",
         "format":"global"
      },
      "jquery.mousewheel":{  
         "defaultExtension":"js",
         "main":"jquery.mousewheel",
         "format":"global"
      },
      "jquery.mCustomScrollbar":{  
         "defaultExtension":"js",
         "main":"jquery.mCustomScrollbar",
         "format":"global"
      },
      "hammerjs":{  
         "defaultExtension":"js",
         "main":"hammer",
         "format":"global"
      },
      "localforage":{  
         "defaultExtension":"js",
         "main":"localforage"
      },
      "wnumb":{  
         "defaultExtension":"js",
         "main":"wnumb",
         "format":"global"
      },
      "clipboard":{  
         "defaultExtension":"js",
         "main":"clipboard",
         "format":"global"
      },
      "materialize-css":{  
         "defaultExtension":"js",
         "main":"materialize",
         "format":"global"
      },
      "noUiSlider":{  
         "defaultExtension":"js",
         "main":"noUiSlider",
         "format":"global"
      },
      "plugin-typescript":{  
         "main":"plugin.js"
      },
      "typescript":{  
         "main":"typescript.js",
         "meta":{  
            "typescript.js":{  
               "exports":"ts"
            }
         }
      }
   },
   "typescriptOptions":{  
      "target":"es5",
      "module":"es6",
      "emitDecoratorMetadata":true,
      "experimentalDecorators":true
   },
   "transpiler":"plugin-typescript"
}
frankwallis commented 7 years ago

This was a duplicate of https://github.com/frankwallis/plugin-typescript/issues/185 and is resolved in 7.0.0