Add type checking and full build creation
This uses Closure Compiler to create a full build and run type checks. Currently type errors are reported as warnings and the build is created with SIMPLE optimizations until we have transitioned all types to path types.
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
"scripts": {
|
||||
"lint": "eslint tasks test src examples transforms",
|
||||
"pretest": "npm run lint",
|
||||
"test": "npm run karma -- --single-run",
|
||||
"test": "npm run karma -- --single-run && npm run build-typecheck",
|
||||
"karma": "karma start test/karma.config.js",
|
||||
"serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --watch & serve build/examples",
|
||||
"build-examples": "webpack --config examples/webpack/config.js --env=prod"
|
||||
"build-examples": "webpack --config examples/webpack/config.js --env=prod",
|
||||
"build-typecheck": "node tasks/generate-index.js && node tasks/build-typecheck.js"
|
||||
},
|
||||
"main": "src/ol/index.js",
|
||||
"repository": {
|
||||
@@ -46,6 +47,7 @@
|
||||
"front-matter": "^2.1.2",
|
||||
"fs-extra": "5.0.0",
|
||||
"glob": "7.1.1",
|
||||
"google-closure-compiler": "^20180101.0.0",
|
||||
"handlebars": "4.0.11",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"istanbul": "0.4.5",
|
||||
|
||||
37
tasks/build-typecheck.js
Normal file
37
tasks/build-typecheck.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const Compiler = require('google-closure-compiler').compiler;
|
||||
|
||||
const compiler = new Compiler({
|
||||
js: [
|
||||
'./src/**.js',
|
||||
'./node_modules/pbf/package.json', './node_modules/pbf/**.js', './node_modules/ieee754/**.js',
|
||||
'./node_modules/pixelworks/package.json', './node_modules/pixelworks/**.js',
|
||||
'./node_modules/rbush/package.json', './node_modules/rbush/**.js', 'node_modules/quickselect/**.js'
|
||||
],
|
||||
entry_point: './src/index.js',
|
||||
module_resolution: 'NODE',
|
||||
//FIXME Use compilation_level: 'ADVANCED' after we have switched to path types
|
||||
compilation_level: 'SIMPLE',
|
||||
new_type_inf: true,
|
||||
generate_exports: true,
|
||||
export_local_property_definitions: true,
|
||||
output_wrapper: '(function(){%output%})() //# sourceMappingURL=ol.js.map',
|
||||
js_output_file: 'build/ol.js',
|
||||
create_source_map: '%outname%.map',
|
||||
source_map_include_content: true,
|
||||
//FIXME Turn jscomp_error on for * when we have path types everywhere
|
||||
//FIXME Change newCheckTypes to jscomp_error when we have path types everywhere
|
||||
jscomp_warning: ['newCheckTypes'],
|
||||
// Options to make dependencies work
|
||||
process_common_js_modules: true,
|
||||
dependency_mode: 'STRICT',
|
||||
hide_warnings_for: 'node_modules'
|
||||
});
|
||||
|
||||
compiler.run((exit, out, err) => {
|
||||
if (exit) {
|
||||
process.stderr.write(err, () => process.exit(exit));
|
||||
} else {
|
||||
process.stderr.write(err);
|
||||
process.stdout.write(out);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user