Skip to content

Commit

Permalink
maint/build ~ normalize 'build' directory structure
Browse files Browse the repository at this point in the history
- enables optional TypeScript test files within 'test'
- *note*: 'build/tests_' is used to avoid erroneous detection of tests by `ava`
  • Loading branch information
rivy committed Feb 14, 2021
1 parent 0ab8eca commit b14340d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .rollup.config.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export default [
// * ref: <https://github.com/Microsoft/TypeScript/issues/4433> , <https://github.com/google/model-viewer/issues/1502>
// * ref: <https://github.com/Swatinem/rollup-plugin-dts>
{
input: './build/types/mod.esm.d.ts',
input: './build/types/src/mod.esm.d.ts',
output: [{ file: './dist/types/mod.d.ts', format: 'esm' }],
plugins: [dts()],
},
{
input: './build/types/mod.cjs.d.ts',
input: './build/types/src/mod.cjs.d.ts',
output: [{ file: './dist/types/mod.cjs.d.ts', format: 'cjs' }],
plugins: [
dts(),
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"build:cjs": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-cjs.succeeded \"run-s -n rebuild:cjs\"",
"build:esm": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-esm.succeeded \"run-s -n rebuild:esm\"",
"build:umd": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-umd.succeeded \"run-s -n rebuild:umd\"",
"build:tests": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-cjs+tests.succeeded \"run-s -n rebuild:tests\"",
"build:tests": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-tests.succeeded \"run-s -n rebuild:tests\"",
"build:types": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source \"rollup.*.config.js\" --source \"src/**\" --target build/.targets/build-types.succeeded \"run-s -n rebuild:types\"",
"# clean # remove build artifacts": "",
"clean": "rimraf build dist",
Expand Down Expand Up @@ -99,10 +99,10 @@
"realclean": "run-s clean && rimraf coverage .nyc_output",
"# rebuild # clean and (re-)build project": "",
"rebuild": "run-s clean build",
"rebuild:cjs": "shx rm -fr build/cjs && tsc -p tsconfig/tsconfig.cjs.json && shx cp -r src/esm-wrapper build/cjs && shx mkdir -p build/.targets && shx touch build/.targets/build-cjs.succeeded",
"rebuild:esm": "shx rm -fr build/esm && tsc -p tsconfig/tsconfig.esm.json && shx cp src/esm-wrapper/package.json build/esm && shx mkdir -p build/.targets && shx touch build/.targets/build-esm.succeeded",
"rebuild:cjs": "shx rm -fr build/cjs && tsc -p tsconfig/tsconfig.cjs.json && shx cp -r src/esm-wrapper build/cjs/src && shx mkdir -p build/.targets && shx touch build/.targets/build-cjs.succeeded",
"rebuild:esm": "shx rm -fr build/esm && tsc -p tsconfig/tsconfig.esm.json && shx cp src/esm-wrapper/package.json build/esm/src && shx mkdir -p build/.targets && shx touch build/.targets/build-esm.succeeded",
"rebuild:umd": "shx rm -fr build/umd && tsc -p tsconfig/tsconfig.umd.json && shx mkdir -p build/.targets && shx touch build/.targets/build-umd.succeeded",
"rebuild:tests": "shx rm -fr build/cjs+tests && tsc -p tsconfig/tsconfig.tests.json && shx mkdir -p build/.targets && shx touch build/.targets/build-cjs+tests.succeeded",
"rebuild:tests": "shx rm -fr build/tests_ && tsc -p tsconfig/tsconfig.tests.json && shx mkdir -p build/.targets && shx touch build/.targets/build-tests.succeeded",
"rebuild:types": "shx rm -fr build/types && tsc -p tsconfig/tsconfig.types.json && shx mkdir -p build/.targets && shx touch build/.targets/build-types.succeeded",
"# retest # clean and (re-)test project": "",
"retest": "run-s clean test",
Expand Down Expand Up @@ -141,7 +141,7 @@
"_:v_tag:exists": "node -e \"v=require('./package.json').version; result=require('child_process').spawnSync('git rev-list refs/tags/v'+v,{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[lint] WARN Missing commit tag v'+v); process.exit(1);}\"",
"_:v_tag:missing": "run-s --silent _:v_tag:exists && exit 1 || exit 0",
"_:update:changelog": "run-s --silent _:exists:git-changelog && git changelog > CHANGELOG.mkd || shx echo \"[update] WARN CHANGELOG not updated\" 1>&2",
"_:update:dist.build": "shx mkdir -p dist && shx rm -fr dist/cjs dist/esm && shx cp -r build/cjs build/esm dist",
"_:update:dist.build": "shx rm -fr dist/cjs dist/esm && shx mkdir -p dist/cjs dist/esm && shx cp -r build/cjs/src/* dist/cjs && shx cp -r build/esm/src/* dist/esm",
"_:update:dist.normalizeEOL": "eolConverter lf dist/**/*.{cjs,js,mjs,ts,json}",
"_:update:dist.pack": "node -e \"delete process.env.NPM_CONFIG_DRY_RUN; name=require('./package.json').name; result=require('child_process').spawnSync('npm pack && shx mkdir -p dist && shx mv '+name+'-*.tgz dist/'+name+'.tgz',{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[update] ERR! Unable to package (into *.tgz) for distribution\\n'+result.stderr); process.exit(1);} else {console.log(result.stdout);};\"",
"_:update:dist.types": "shx mkdir -p dist && shx rm -fr dist/types && rollup --config .rollup.config.types.js && shx mkdir -p dist/cjs && shx cp dist/types/*.cjs.d.ts dist/cjs",
Expand Down Expand Up @@ -214,7 +214,7 @@
"timeout": "60s",
"typescript": {
"rewritePaths": {
"src/": "build/cjs+tests/"
"src/": "build/tests_/src/"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const test = require('ava');
const commandExists = require('command-exists');
const spawn = require('cross-spawn');

const module_ = require('../build/cjs+tests/mod.cjs.js');
const module_ = require('../build/tests_/src/mod.cjs.js');

const vNodeJS = process.versions.node.split('.');
const vNodeJSMajor = +vNodeJS[0];
Expand Down
2 changes: 1 addition & 1 deletion test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const path = require('path');

const test = require('ava');

const osPaths = require('../build/cjs+tests/mod.cjs.js');
const osPaths = require('../build/tests_/src/mod.cjs.js');

const isWinOS = /^win/i.test(process.platform);

Expand Down
1 change: 1 addition & 0 deletions tsconfig/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/cjs",
"rootDir": "..",
"declaration": false, // generate side-by-side type declarations
"module": "CommonJS",
"noEmit": false
Expand Down
1 change: 1 addition & 0 deletions tsconfig/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/esm",
"rootDir": "..",
"declaration": false, // generate side-by-side type declarations
"module": "es2015",
"noEmit": false
Expand Down
6 changes: 4 additions & 2 deletions tsconfig/tsconfig.tests.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/cjs+tests",
"outDir": "../build/tests_",
"rootDir": "..",
"declaration": true, // generate side-by-side type declarations
"module": "CommonJS",
"noEmit": false,
Expand All @@ -11,7 +12,8 @@
"../eg/**",
"../src/esm-wrapper/**",
"../src/**/*.deno.ts",
"../test/**",
"../test/**/*.js",
"../test/**/*.test-d.ts",
"../node_modules/**"
]
}
1 change: 1 addition & 0 deletions tsconfig/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
// generate (only) type declaration files to 'build/types'
"outDir": "../build/types",
"rootDir": "..",
"declaration": true, // generate type declarations
"emitDeclarationOnly": true,
"noEmit": false,
Expand Down
1 change: 1 addition & 0 deletions tsconfig/tsconfig.umd.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/umd",
"rootDir": "..",
"declaration": false, // generate side-by-side type declarations
"module": "UMD",
"noEmit": false,
Expand Down

0 comments on commit b14340d

Please sign in to comment.