webpack是否支持异步加载CDN的文件?

#1

在SystemJS中可以这样:

 // loads relative to the current page URL
  System.import('./local-module.js'); 

  // load from an absolute URL directly
  System.import('https://code.jquery.com/jquery.js');

System.import('./app/es6-file.js').then(function(m) {
      console.log(new m.q().es6); // yay
    });

webpack2 有谁研究过?有这些特性吗?

#2

支持的, 用 publicPath 控制, 需要找一下例子

#3

我的意思是通过固定的语法请求这个文件,而不是放入<script>,可以吗?
另外这个文件路径在编码的时候是未知的,在某个特殊的时候后端告诉前端路径

#4

SystemJS 是属于 CommonJS 规范还是es6规范?

#5

我没看清楚描述, 但是即便开启了异步加载, publicPath 依然是有效的

#6

publicPath 是有效的,

在SystemJS中可以这样:

 // loads relative to the current page URL
  System.import('./local-module.js'); 

  // load from an absolute URL directly
  System.import('https://code.jquery.com/jquery.js');

System.import('./app/es6-file.js').then(function(m) {
      console.log(new m.q().es6); // yay
    });

webpack2 有谁研究过?有这些特性吗?

#7

支持 ES6 modules, AMD, CommonJS and global scripts

#8

从其他网站引用的代码… 这个有点狠.

#9

看来webpack暂时是没这种支持了,只能采用第三方库。不过也够用了。实现希望加载 ES6 modules, AMD, CommonJS and global scripts的话,应该也可以使用 SystemJS