* Build minified for production
And use dev build in CI
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Rename scripts:
nothing -> default dev build
:prod -> production build
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Trigger build analysis output on demand via an env variable
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Always register source map support.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Revert to one build output for coverage on sonar cloud.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Revert "Revert to one build output for coverage on sonar cloud."
This reverts commit
f3d990ba9878e4e6f097844cacba9e8e4b4c9121.
* Try with sourcemap: false
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Build with sourcemap: true
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Go back to previous sourcemap setting.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* Change sonar sources
Co-authored-by: Alessandro Pio Ardizio <alessandroardizio94@gmail.com>
node-version: 12
- run: npm ci
- run: npm run lint
- - run: npm run test
+ - run: npm run test:prod
- run: npm run coverage
publish-npm:
.history/
.scannerwork
lib
-lib.min
.nyc_output/
coverage/
lib/
-lib.min/
"request": "launch",
"name": "Launch Test Debug",
"cwd": "${workspaceFolder}",
- "preLaunchTask": "Development build",
+ // "preLaunchTask": "Development build",
"runtimeExecutable": "npm",
- "runtimeArgs": ["run-script", "test:debug:vscode"],
+ "runtimeArgs": ["run-script", "test:debug"],
"skipFiles": ["<node_internals>/**"],
"stopOnEntry": true
},
"request": "launch",
"name": "Launch Benchmark Debug",
"cwd": "${workspaceFolder}",
- "preLaunchTask": "Development build",
+ // "preLaunchTask": "Development build",
"runtimeExecutable": "npm",
- "runtimeArgs": ["run-script", "benchmark:debug:vscode"],
+ "runtimeArgs": ["run-script", "benchmark:debug"],
"skipFiles": ["<node_internals>/**"],
"stopOnEntry": true
}
{
"version": "2.0.0",
"tasks": [
+ {
+ "label": "Build",
+ "type": "npm",
+ "script": "build:prod"
+ },
{
"label": "Development build",
"type": "npm",
- "script": "build:dev"
+ "script": "build"
}
]
}
"description": "Library on top of node js worker threads that implement various worker pools type",
"main": "lib/index.js",
"scripts": {
- "build": "rollup --config",
- "build:dev": "rollup --config --environment BUILD:development",
- "benchmark": "npm run build && node benchmarks/bench.js",
- "benchmark:debug": "npm run build:dev && node -r source-map-support/register --inspect-brk benchmarks/bench.js",
- "benchmark:debug:vscode": "node -r source-map-support/register benchmarks/bench.js",
- "test": "npm run build && nyc mocha --exit --timeout 20000 tests/**/*.test.js",
- "test:debug": "npm run build:dev && mocha -r source-map-support/register --inspect-brk --exit tests/**/*.test.js",
- "test:debug:vscode": "mocha -r source-map-support/register --exit tests/**/*.test.js",
+ "build": "rollup --config --environment BUILD:development",
+ "build:prod": "rollup --config",
+ "benchmark": "npm run build && node -r source-map-support/register benchmarks/bench.js",
+ "benchmark:debug": "npm run build && node -r source-map-support/register --inspect benchmarks/bench.js",
+ "benchmark:prod": "npm run build:prod && node -r source-map-support/register benchmarks/bench.js",
+ "test": "npm run build && nyc mocha -r source-map-support/register --exit --timeout 20000 tests/**/*.test.js",
+ "test:debug": "npm run build && mocha -r source-map-support/register --inspect --exit --timeout 20000 tests/**/*.test.js",
+ "test:prod": "npm run build:prod && nyc mocha -r source-map-support/register --exit --timeout 20000 tests/**/*.test.js",
"sonar": "sonar-scanner",
"coverage": "nyc report --reporter=lcov --check-coverage --lines 80",
"coverage:html": "nyc report --reporter=html --check-coverage --lines 80",
import del from 'rollup-plugin-delete'
const isDevelopmentBuild = process.env.BUILD === 'development'
+const isAnalyze = process.env.ANALYZE
export default {
input: 'src/index.ts',
- output: [
- {
- dir: 'lib',
- format: 'cjs',
- sourcemap: !!isDevelopmentBuild,
- preserveModules: true,
- preserveModulesRoot: 'src'
- },
- isDevelopmentBuild && {
- file: 'lib.min/index.js',
- format: 'cjs',
- sourcemap: !!isDevelopmentBuild,
- plugins: [terser({ numWorkers: 2 })]
- }
- ],
+ output: {
+ ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
+ format: 'cjs',
+ sourcemap: !!isDevelopmentBuild,
+ ...(isDevelopmentBuild && { preserveModules: true }),
+ ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
+ ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
+ },
external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
plugins: [
typescript({
: 'tsconfig.json'
}),
del({
- targets: ['lib/*', 'lib.min/*']
+ targets: ['lib/*']
}),
- isDevelopmentBuild && analyze()
+ isAnalyze && analyze()
]
}
sonar.projectName=poolifier
sonar.projectVersion=2.0.0
sonar.host.url=https://sonarcloud.io
-sonar.sources=lib
+sonar.sources=src
sonar.tests=tests
# sonar.login=TOKEN #To use for local troubleshooting
sonar.verbose=false