js-dxtools/webpack-validator

Use TypeScript type definition to generate schema?

bebraw opened this issue · 5 comments

I just came by TypeScript type definition for webpack configuration. Maybe it would be sensible to use that as a base for other tools like webpack-validator? This would be helpful in many places. Ideally the type definition would be maintained within webpack core.

Yes precisely. Or simply writing webpack configs in typescript and using ts-node, will automagically statically typecheck your config properties, out of the box.

cc @gdi2290

Now that webpack 2 (current beta) implements JSON Schema, you could probably piggyback on that.

@TheLarkInn I'm actually working with ts config files for webpack 2, also using ES6 imports.

Just recently found this package, does it means that when using typescript with ts-node, makes this package unnecessary?

I tried it but since it doesn't run with ts-node it complains in the ES6 imports part:

...tao-graphql-api/config/webpack.dev.ts:5
import webpack from 'webpack';
^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)

@Luchillo I think the coolest option would be to experiment with JSON Schema to TypeScript definition converters and integrate that to webpack core if it works well. You should be able to get nicer developer experience in TypeScript environment then.

I think I'll close this issue as it's not likely going to happen. It's better to work with the schema in the core.

I'm running the webpack command with ts files directly and it does give me some nice error checking.