diff --git a/.travis.yml b/.travis.yml index f5ff07ee1..f1db566d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ +language: node_js +node_js: + - "node" script: -- cd tns-core-modules && npm i && cd .. +# circular references check +- cd tests && npm i +- node_modules/.bin/webpack --env.android +- node_modules/.bin/webpack --env.ios +# modules transpilation +- cd ../tns-core-modules && npm i && cd .. - npm install - npm run tsc - npm run tslint diff --git a/tests/package.json b/tests/package.json index b1a3a76c6..1f1974f23 100644 --- a/tests/package.json +++ b/tests/package.json @@ -16,6 +16,7 @@ "tns-core-modules": "file:../tns-core-modules" }, "devDependencies": { + "circular-dependency-plugin": "5.2.0", "nativescript-dev-webpack": "next", "node-sass": "^4.12.0", "tns-platform-declarations": "file:../tns-platform-declarations", diff --git a/tests/webpack.config.js b/tests/webpack.config.js index a084e6fe9..574fd1a57 100644 --- a/tests/webpack.config.js +++ b/tests/webpack.config.js @@ -3,6 +3,7 @@ const { join, relative, resolve, sep } = require("path"); const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); +const CircularDependencyPlugin = require('circular-dependency-plugin'); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); @@ -11,6 +12,10 @@ const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeS const TerserPlugin = require("terser-webpack-plugin"); const hashSalt = Date.now().toString(); +const ANDROID_MAX_CYCLES = 68; +const IOS_MAX_CYCLES = 39; +let numCyclesDetected = 0; + module.exports = env => { // Add your custom Activities, Services and other Android app components here. const appComponents = [ @@ -230,6 +235,32 @@ module.exports = env => { "global.TNS_WEBPACK": "true", "process": "global.process", }), + new CircularDependencyPlugin({ + onStart({ compilation }) { + console.log('start detecting webpack modules cycles'); + numCyclesDetected = 0; + }, + onDetected({ module: webpackModuleRecord, paths, compilation }) { + numCyclesDetected++; + compilation.warnings.push(new Error(paths.join(' -> '))) + }, + onEnd({ compilation }) { + console.log('end detecting webpack modules cycles'); + if (platform === "android" && numCyclesDetected !== ANDROID_MAX_CYCLES) { + compilation.errors.push(new Error( + `Detected ${numCyclesDetected} cycles which differs configured limit of ${ANDROID_MAX_CYCLES}.` + )); + } else if (platform === "ios" && numCyclesDetected !== IOS_MAX_CYCLES) { + compilation.errors.push(new Error( + `Detected ${numCyclesDetected} cycles which differs configured limit of ${IOS_MAX_CYCLES}.` + )); + } else { + compilation.warnings.push(new Error( + `${numCyclesDetected} cycles detected.` + )); + } + }, + }), // Remove all files from the out dir. new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }), // Copy assets to out dir. Add your own globs as needed.