Skip to content

Commit

Permalink
Deprecate (most of) typings in favour of the new @types/ workflow
Browse files Browse the repository at this point in the history
Some caveats:

* The new typings are kinda broken, so we don't use import statements on webpack + related plugins
* That means we essentially aren't generally using the typings provided by Webpack, since Webpack's typings are kinda broken.
* Unfortunately, screepers/Screeps-TypeScript-Declarations doesn't seem to have any typings available, so atm it we still have to retrieve them via typings.
  • Loading branch information
resir014 committed Aug 22, 2017
1 parent 941c8e3 commit db3d371
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions config/config.common.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as path from "path";
import * as webpack from "webpack";
import * as Config from "webpack-chain";
import { ScreepsSourceMapToJson } from "../libs/screeps-webpack-sources";

// Plugins:
// Webpack + plugins:
// disable tslint rule, because we don't have types for these files
/* tslint:disable:no-var-requires */
/* tslint:disable:no-require-imports */
const webpack = require('webpack');
const { CheckerPlugin, TsConfigPathsPlugin } = require("awesome-typescript-loader");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const git = require("git-rev-sync");
Expand Down
10 changes: 5 additions & 5 deletions libs/screeps-webpack-sources.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as path from "path";
import * as webpack from "webpack";
import { Plugin } from "webpack";

// disable tslint rule, because we don't have types for these files
/* tslint:disable:no-var-requires */
/* tslint:disable:no-require-imports */
const ConcatSource = require("webpack-sources").ConcatSource;

// Tiny tiny helper plugin that prepends "module.exports = " to all `.map` assets
export class ScreepsSourceMapToJson implements webpack.Plugin {
export class ScreepsSourceMapToJson implements Plugin {
// constructor(_options: any) {
// // we don't use options
// }

public apply(compiler: webpack.Compiler) {
compiler.plugin("emit", (compilation, cb) => {
public apply(compiler: any) {
compiler.plugin("emit", (compilation: any, cb: any) => {
for (const filename in compilation.assets) {
// matches any files ending in ".map" or ".map.js"
if (path.basename(filename, ".js").match(/\.map/)) {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
},
"homepage": "https://github.com/resir014/Stonehenge#readme",
"devDependencies": {
"@types/lodash": "3.10.0",
"@types/node": "7.0.0",
"@types/screeps-profiler": "^1.2.0",
"@types/source-map": "^0.5.1",
"@types/webpack": "2.2.0",
"@types/webpack-chain": "^3.0.4",
"awesome-typescript-loader": "^3.1.3",
"clean-webpack-plugin": "^0.1.16",
"git-rev-sync": "^1.9.1",
Expand Down
7 changes: 1 addition & 6 deletions typings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"name": "resir014-screeps",
"dependencies": {
"tapable": "registry:dt/tapable#0.2.5+20161220195540",
"webpack": "registry:dt/webpack#2.2.0+20170320160659",
"webpack-chain": "registry:dt/webpack-chain#3.0.0+20170322005926"
},
"dependencies": {},
"globalDependencies": {
"lodash": "registry:dt/lodash#3.10.0+20160619033623",
"screeps": "github:screepers/Screeps-Typescript-Declarations/dist/screeps.d.ts"
}
}
2 changes: 1 addition & 1 deletion webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function webpackConfig(options: EnvOptions = {}): webpack.Configuration {
const config: Config = require(`./config/config.${options.ENV}`)(options);

// call `toConfig` to convert to webpack object, and return it
return config.toConfig();
return config.toConfig() as webpack.Configuration;
}

module.exports = webpackConfig;

0 comments on commit db3d371

Please sign in to comment.