Phil 3.2.15

8:00 – 6:30 SR

  • The world is a sheet of ice. Working from home.
  • Was able to update my directory, but the watcher in IntelliJ is based on save actions in the file you’re editing. This is horribly frustrating in that sometimes the whole project needs to compile based on dependencies. The answer for this appears to be Grunt, and it looks like the process is laid out here.
  • Timesheets are working!
  • Ok, everything below this line is a rant, basically. If you want to know what wound up working, read here.
  • Installing Grunt, which has caused IntelliJ to completely freeze “Scanning files to index”. This is really pathetic.  Going to go scrape ice for a while and hope that my Xenon 3.3Ghz tower with 8 GB of ram can finish scanning some JavaScript Files. It may be a memory issue. From StackOverflow:

    I had the same problem with slowness in IntelliJ 13 after upgrading from 12. What worked for me was editing the idea64.vmoptions in the bin folder and setting the max heap to 8 GB (was 512 MB) and the Max PermGen to at least 1GB (was 300MB).Example below:
    -Xms128m
    -Xmx8192m
    -XX:MaxPermSize=1024m
    Upon restart it was much faster.

    Then again, it may not be. I started to get error messages on the install that had hugely deep paths. A *lot* (30,000 files!) of stuff was getting installed. More than needed. Deleting it all and trying again from outside the IDE. If that doesn’t work, then I’m going to change the watcher so that it compiles all items explicitly.

      • Nope, disregard all of the above. The enormous install was because I had mistaken
      • npm install grunt-contrib-watch –save-dev
      • from
      • npm install grunt-contrib-watch –save -dev
      • when it should have been
        npm install grunt-contrib-watch -–save-dev
      • You know, this is because all of us developers are all looking for things that work and documenting it just when we get it running. No extensive tests that go along with books, just flaliing and commenting. Anyway, I got grunt to work, and have now run up against some weird typescript problem.
      • When you take each individual typescript file and compile it, as the IntelliJ watcher does, I get no errors. Here’s my code files:
        tsc --declaration --noImplicitAny --target ES5 --sourcemap classes/WebGlInterfaces.ts
        tsc --declaration --noImplicitAny --target ES5 --sourcemap classes/WebGlCanvasClasses.ts
        tsc --declaration --noImplicitAny --target ES5 --sourcemap classes/WebGlComponentClasses.ts
        tsc --declaration --noImplicitAny --target ES5 --sourcemap controllers/WGLA1_controller.ts
        tsc --declaration --noImplicitAny --target ES5 --sourcemap directives/WGLA2_directives.ts
        tsc --declaration --noImplicitAny --target ES5 --sourcemap modules/AppMain.ts
      • However, when I compile all on a single line (as Grunt does), I get the following errors:
        classes/WebGlCanvasClasses.d.ts(12,11): error TS2300: Duplicate identifier 'StyleElement'.
        classes/WebGlCanvasClasses.d.ts(29,11): error TS2300: Duplicate identifier 'CanvasBase'.
        .......... lots more errors................
        directives/WGLA2_directives.ts(67,12): error TS2341: Property 'linkFn' is private and only accessible within class 'ngWebgl'.
        directives/WGLA2_directives.ts(70,11): error TS2341: Property 'myDirective' is private and only accessible within class 'ngWebgl'.
      • Because like all modern code it seems, Grunt has a large set of plugins to do the same thing. In this case, we have grunt-typescript, and grunt-ts. Very similar. Only grunt-ts allows you to specify individual compile targets, which is what I need to avoid the compile errors listed above.
      • So to get all the pieces working together, first install grunt globally as per here. Once that’s done go to the root of your project directory and type the following:
        npm init
        npm install grunt -–save-dev
        npm install grunt-ts -–save-dev
        npm install grunt-contrib-watch -–save-dev
      • Once that’s done, you need to create a GruntFile.js. Here’s what works for me:
        module.exports = function (grunt) {
            grunt.loadNpmTasks('grunt-ts');
            grunt.loadNpmTasks('grunt-contrib-watch');
        
            grunt.initConfig({
                pkg: grunt.file.readJSON('package.json'),
        
                ts: {
                    default: {
                        files:[
                            {src:['classes/WebGlInterfaces.ts'], dest: 'classes/WebGlInterfaces.js'},
                            {src:['classes/WebGlCanvasClasses.ts'], dest: 'classes/WebGlCanvasClasses.js'},
                            {src:['classes/WebGlComponentClasses.ts'], dest: 'classes/WebGlComponentClasses.js'},
                            {src:['controllers/WGLA1_controller.ts'], dest: 'controllers/WGLA1_controller.js'},
                            {src:['directives/WGLA2_directives.ts'], dest: 'directives/WGLA2_directives.js'},
                            {src:['modules/AppMain.ts'], dest: 'modules/AppMain.js'}
                        ]
                    },
                    options : {
                        fast : 'watch',
                        declaration: true,
                        noImplicitAny:true,
                        verbose:true,
                        target: 'es5',
                        sourcemap:true
                    }
                },
                watch: {
                    files: ['**/*.ts', '!**/*.d.ts'],
                    tasks: ['ts']
                }
        
            });
        
            grunt.registerTask('default', ['watch']);
        
        }
        
        

         

     

  • Once that’s done, type ‘grunt’ at the command line and you should get the following:
    >grunt
    Running "watch" task
    Waiting...
  • At this point, a change in any of the ts files will cause all the ts files to compile to their respective .d.ts and .js files. This is better, but I still want dependency chaining. Still looking for that.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: