我正在研究 angular2 + typescript 应用程序。
我看到@angular 包是如何工作的:
如果你安装@angular/common,你的node_modules文件夹中会有:
@angular/core
|---bundles
| |---core.umd.js
|
|---src (all transpiled code)
|---index.js
所以,多亏了index.js....以及所有转译的代码src,导入喜欢
import { NgModule } from "@angular/core";让我编译应用程序;
但是,在我的 output/dist 文件夹中,我没有也没有转译文件,这要归功于 SystemJs,它使使用库变得非常简单 :index.js.umd.js
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: '',
// angular bundles
'@angular/core': 'lib/@angular/core/bundles/core.umd.js',
'@angular/common': 'lib/@angular/common/bundles/common.umd.js',
'mylib1': 'lib/mylib1/bundles/mybundlelib1.umd.js',
'mylib2: 'lib/mylib2/bundles/mybundlelib2.umd.js',
.........................
.........................
我正在寻找的是即使使用 webpack 也能做到这一点的方法;
我自己用 webpack 创建了一些库/包,我想在我的 webpack 应用程序中使用它们。
在node_modules应用程序的文件夹中,我将具有与角度包相同的结构:
mylib1
|---bundles
| |---mybundlelib.umd.js
|
|---src (all transpiled code)
|---index.js
所以我可以使用index.js和src编译语句
import { libClass } from "mylib1";....但...
至于 SystemJs,我将负责将 JUST 包复制到我的 output/dist 文件夹中,然后...
1) 我不想将它们放入 Vendor 捆绑包中;
2)我不想使用他们的转译代码通过应用程序的 webpack 配置创建一个新包。
你能帮助我吗 ??
更具体地说,我只想在我的 webpack 应用程序中使用第三方库;
因此,在我的应用程序的任何其他部分附近,app.js我希望有一些外部捆绑库来使用它们。vendor.jsindex.html