首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeScript 2.1.4 webpack ts加载器的突破性变化

TypeScript 2.1.4 webpack ts加载器的突破性变化
EN

Stack Overflow用户
提问于 2016-12-22 12:07:52
回答 0查看 607关注 0票数 2

从Typescript 2.0.10升级到2.1.4似乎破坏了webpack、webpack-stream、ts-loader或gulp中的某些东西,因为它不再尊重我的入口点或glob源。它似乎包含我的项目中的所有.ts文件(包括/server源文件夹中的文件),而不是像gulp.src和web包入口点那样只包含/client和app.ts中的ts文件。有没有不同的/更新的/更好的方法呢?

在gulp文件中:

代码语言:javascript
复制
const serverPath = 'server';
const clientPath = 'client';
const buildPath = 'build';
const paths = {
    server: {
        scripts: [
            `${serverPath}/**/*.ts`
        ]
    },
    client: {
        files: [
            `${clientPath}/**/*`
        ],
        scripts: [
            `${clientPath}/**/*.ts`
        ],
        entry: `${clientPath}/app.ts`
    }
};


gulp.task('build:client', cb => {
    gulp.src(paths.client.entry)
        .pipe(webpackStream(webpackConfig, webpack))
        .pipe(gulp.dest(`${buildPath}/${clientPath}`));
    cb();
});

在web包配置中:

代码语言:javascript
复制
entry: {
    app: './client/app.ts'
}

ts: {
    configFileName: './tsconfig.json'
}

resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
}

module: {
    loaders: [
        { test: /\.ts$/, loader: 'ng-annotate-loader!ts-loader' }
    ]
}

在tsconfig.json中:

代码语言:javascript
复制
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "removeComments": false,
        "noImplicitAny": true,
        "sourceMap": true,
        "inlineSources": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    }
}

使用2.0.10的输出:

代码语言:javascript
复制
ts-loader: Using typescript@2.0.10 and /Users/chris/code/class-app/tsconfig.json
[20:47:36] Version: webpack 1.14.0
Asset       Size  Chunks             Chunk Names
app.js.map  950 bytes       0  [emitted]  app
app.js  550 bytes       0  [emitted]  app

使用2.1.4的输出:

代码语言:javascript
复制
ts-loader: Using typescript@2.1.4 and /Users/chris/code/class-app/tsconfig.json
server/api/thing/thing.controller.ts(17,16): error TS2322: <ts error in server portion, not relevant>
[20:53:03] TypeScript: 1 semantic error
[20:53:03] TypeScript: emit succeeded (with errors)
Unhandled rejection Error in plugin 'webpack-stream'
Message:
/Users/chris/code/class-app/server/api/thing/thing.controller.ts <same as above>
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41275637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档