【发布时间】:2016-02-26 09:49:17
【问题描述】:
我有以下文件夹结构
dist
src
module1
m1.ts
module2
m2.ts
.tsconfig.json
...
我已将tsc 配置为输出到dist/js,因此在运行npm run tsc 后,我有以下内容:
dist
js
module1
m1.js
module2
m2.js
src
...
经过一番努力,我设法将ng-bootstrap 集成到我的项目中。
如果我在我的应用程序某处从ng2-bootstrap import import,例如:
import { ACCORDION_DIRECTIVES } from 'ng2-bootstrap/components/accordion';
并运行npm run tsc 我的文件夹结构更改为:
dist
js
node_modules
ng2-bootstrap
components
accordian
...
src
module1
m1.js
module2
m2.js
src
....
为什么会这样?
我的index.html 中包括:<script src="/vendor/ng2-bootstrap/bundles/ng2-bootstrap.js"></script>
我可以用 angular2 做到这一点
<script src="/vendor/angular2/bundles/angular2.dev.js"></script>
和
import {Component} from 'angular2/core',这不会创建 dist/js/node_modules/angular2 文件夹
更新
这是我的 tsconfig.json 的内容
{
"compilerOptions": {
"target": "ES5",
"outDir": "./dist/js",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"dist",
"typings/main",
"typings/main.d.ts"
]
}
【问题讨论】:
-
你能给我们你的
tsconfig.json吗?谢谢! -
另外可能值得一提的是,我在
tsconfig.json中设置了"rootDir": "./src",在"import .. from "ng2-bootstrap.."之前一直很好,然后在运行npm run tsc时我会收到错误..node_modules/ng2-bootstrap/components/accordion.ts' is not under 'rootDir' 'src'. -
引用这个 repo 结构 github.com/MrPardeep/Angular2-DatePicker 看起来和这个 repo 的结构一样
-
我也有同样的问题。导入 ng2-bootstrap 在我的 dist 文件夹中创建 node_modules 作为 src 的兄弟(如果不存在 ng2-bootstrap 导入,编译的内容将直接进入 dist)。我提供赏金,以引起打字员的注意。
标签: typescript angular tsc ng2-bootstrap