js-dxtools / webpack-validator

Validates your webpack config with Joi
MIT License
295 stars 29 forks source link

Use TypeScript type definition to generate schema? #114

Closed bebraw closed 7 years ago

bebraw commented 8 years ago

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.

TheLarkInn commented 8 years ago

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

bebraw commented 8 years ago

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

luchillo17 commented 7 years ago

@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)
bebraw commented 7 years ago

@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.

luchillo17 commented 7 years ago

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