2016-11-11 49 views

回答

0

有多種方式可以在瀏覽器中支持模塊: AMD,CommonJS,UMD和RequireJS(僅限瀏覽器)。在你的具體例子中,我認爲webpack會將所有的模塊打包在一起(參見該項目中的dev依賴項和webpack config in the project)。 見:

  1. https://webpack.github.io/docs/api-in-modules.html
  2. How to require CommonJS modules in the browser?
  3. https://pixelsvsbytes.com/2013/02/js-require-for-browsers-better-faster-stronger/
  4. https://addyosmani.com/writing-modular-js/

的NodeJS需要是一個全球性的功能: 參見: How does require() in node.js work?