webpack - angular 4, globally import external javascript -


i know question has been asked before, after searching , trying tons of things have ask.

i'm using angular starter package , try import external javascript library

i have no problem importing directly component so

import * loadimage 'blueimp-load-image/js/index.js'; 

but far know should import external scripts (with async operations) before zone.js because may otherwise cause problems change detection. in fact problem i'm experiencing safari in ios. have manually call change detection.

in angular starter package zone.js required in file called polyfills.ts added chunk/js file webpack.

import 'blueimp-javascript-to-blob-for-angular'; //how import it's useable in component? import 'blueimp-load-image/js/index'; import 'core-js/es6'; import 'core-js/es6/set'; import 'core-js/es7/reflect';  require('zone.js/dist/zone');  if ('production' !== env) {     error['stacktracelimit'] = infinity;     require('zone.js/dist/long-stack-trace-zone'); } 

how , can import external javascript file (content below) before zone.js can still use in component?

so far problem has been can't acccess external libraries functions because undefined. have been added generated javascript files.

the whole process of importing external javascript angular 4 project seems complicated me.

content of javascript file:

module.exports = require('./load-image')  require('./load-image-scale') require('./load-image-meta') require('./load-image-fetch') require('./load-image-exif') require('./load-image-exif-map') require('./load-image-orientation') 

if you're using addassethtmlplugin shown here

  /**    * plugin: addassethtmlplugin    * description: adds given js or css file files    * webpack knows about, , put list of assets    * html-webpack-plugin injects generated html.    *    * see: https://github.com/simenb/add-asset-html-webpack-plugin    */   // new addassethtmlplugin([   //   { filepath: helpers.root(`dll/${dllbundlesplugin.resolvefile('polyfills')}`) },   //   { filepath: helpers.root(`dll/${dllbundlesplugin.resolvefile('vendor')}`) }   // ]), 

you need create entry point here require external js file , load using addassethtmlplugin plugin before other bundles.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -