tpadjen / ng2-prism

An Angular2 codeblock highlighting component using Prismjs.
http://braceyourself.io/ng2-prism
41 stars 15 forks source link

ng2-prism doesn't compile anymore: AppViewManager removed from Angular2 rc1 #6

Open bbottema opened 8 years ago

bbottema commented 8 years ago

ng2-prism still uses old classes from Angular2 since rc1, causing https://github.com/angular/angular2-seed/issues/79.

Shoocky commented 8 years ago

any workaround or ng2-prism alternative?

bbottema commented 8 years ago

@Shoocky I'm requiring the library distribution using webpack manually (instead of importing it from the source files), which I acquired from Prism's download builder. Then using Angular's AfterViewChecked lifecycle event I use the global Prism reference (unfortunately).

In the .ts file where I need it:

declare var Prism:any;

require('./lib/prism.ts');

export class YourApp implements AfterViewChecked {
  ngAfterViewChecked():any {
    return Prism.highlightAll();
  }
}

Then to prevent it from being included in my own bundle:

In external.ts (for any other libraries I need to bootstrap this way):

require('./app/lib/prism.ts');

In webpack.config.js:

  entry: {
    'polyfills': './src/polyfills.ts',
    'vendor': './src/vendor.ts',
    'external': './src/external.ts',
    'app': './src/app.ts'
  }

Also include in the CommonsChunkPlugin entry of webpack.config.js.