Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: migrate to ts project references #28

Merged
merged 3 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": "./tsconfig.json"
"project": "packages/*/{src,test}/tsconfig.json"
},
"extends": [
"plugin:@typescript-eslint/recommended",
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
node-version: [14, 12, 10]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g yarn@1
- run: yarn
- run: yarn test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g yarn@1
- run: yarn
- run: yarn build
- run: yarn lint
- run: yarn test
5 changes: 0 additions & 5 deletions .mocharc.js

This file was deleted.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"packages/*"
],
"scripts": {
"clean": "lerna run clean --stream --parallel",
"build": "lerna run build --stream",
"clean": "rimraf ./packages/*/dist",
"build": "tsc --build",
"watch": "yarn build -w",
"test": "mocha \"./packages/*/dist/**/*.unit.js\" --enable-source-maps",
"lint": "eslint . -f codeframe",
"pretest": "yarn build && yarn lint",
"test": "lerna run test --stream --parallel",
"prettify": "prettier \"./**/*.{js,ts,tsx,md}\" --write"
"prettify": "prettier . --write"
},
"devDependencies": {
"@types/chai": "^4.2.11",
Expand Down Expand Up @@ -41,6 +41,12 @@
"printWidth": 120,
"singleQuote": true
},
"mocha": {
"colors": true,
"require": [
"@ts-tools/robotrix/dist/test/chai-setup"
]
},
"author": "Avi Vahl <avi.vahl@wix.com>",
"license": "MIT",
"private": true
Expand Down
3 changes: 3 additions & 0 deletions packages/build/bin/ts-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/cli');
3 changes: 0 additions & 3 deletions packages/build/cli.js

This file was deleted.

17 changes: 7 additions & 10 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
"name": "@ts-tools/build",
"version": "1.2.6",
"description": "CLI for easier building of multi-target TypeScript libraries.",
"main": "./cjs/index.js",
"types": "./cjs/index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"ts-build": "./cli.js"
},
"scripts": {
"clean": "rimraf ./cjs",
"prebuild": "yarn clean",
"build": "tsc -p tsconfig.build.json"
"ts-build": "./bin/ts-build.js"
},
"peerDependencies": {
"typescript": ">=2.8.0"
Expand All @@ -21,9 +16,11 @@
"commander": "^5.1.0"
},
"files": [
"cjs",
"bin",
"dist",
"!dist/test",
"src",
"cli.js"
"!*/tsconfig.{json,tsbuildinfo}"
],
"author": "Avi Vahl <avi.vahl@wix.com>",
"license": "MIT",
Expand Down
11 changes: 11 additions & 0 deletions packages/build/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist"
},
"references": [
{
"path": "../../transpile/src/tsconfig.json"
}
]
}
10 changes: 0 additions & 10 deletions packages/build/tsconfig.build.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/fixtures/index.ts

This file was deleted.

12 changes: 6 additions & 6 deletions packages/fixtures/tsconfig.tsc-init.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand All @@ -25,7 +25,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
Expand All @@ -48,7 +48,7 @@
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

Expand All @@ -63,7 +63,7 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
14 changes: 5 additions & 9 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
"name": "@ts-tools/node",
"version": "1.1.3",
"description": "TypeScript support for Node.js.",
"main": "./cjs/index.js",
"types": "./cjs/index.d.ts",
"scripts": {
"clean": "rimraf ./cjs",
"prebuild": "yarn clean",
"build": "tsc -p tsconfig.build.json",
"test": "mocha \"./test/**/*.unit.ts\""
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"peerDependencies": {
"typescript": ">=2.8.0"
},
Expand All @@ -18,8 +12,10 @@
"source-map-support": "^0.5.19"
},
"files": [
"cjs",
"dist",
"!dist/test",
"src",
"!*/tsconfig.{json,tsbuildinfo}",
"r.js"
],
"author": "Avi Vahl <avi.vahl@wix.com>",
Expand Down
2 changes: 1 addition & 1 deletion packages/node/r.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./cjs/register');
require('./dist/register');
11 changes: 11 additions & 0 deletions packages/node/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist"
},
"references": [
{
"path": "../../transpile/src/tsconfig.json"
}
]
}
5 changes: 3 additions & 2 deletions packages/node/test/node-extension.unit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect } from 'chai';
import { join, sep } from 'path';
import { join, sep, dirname } from 'path';
import { platform } from 'os';
import { spawnSync } from 'child_process';
import { fixturesRoot } from '@ts-tools/fixtures';

const fixturesRoot = dirname(require.resolve('@ts-tools/fixtures/package.json'));

export function runCommand(command: string): { output: string; exitCode: number } {
const [execName, ...args] = command.split(' ');
Expand Down
12 changes: 12 additions & 0 deletions packages/node/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/test",
"types": ["node", "mocha"]
},
"references": [
{
"path": "../src/tsconfig.json"
}
]
}
10 changes: 0 additions & 10 deletions packages/node/tsconfig.build.json

This file was deleted.

20 changes: 6 additions & 14 deletions packages/robotrix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@
"name": "@ts-tools/robotrix",
"version": "1.0.4",
"description": "Useful TypeScript transpilation transformers.",
"main": "./cjs/index.js",
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"scripts": {
"clean": "rimraf ./cjs ./esm",
"prebuild": "yarn clean",
"build": "yarn build:cjs && yarn build:esm",
"build:cjs": "tsc -p tsconfig.build.json --outDir cjs --module commonjs",
"build:esm": "tsc -p tsconfig.build.json --outDir esm --module esnext",
"test": "mocha -r @ts-tools/node/r -r test/chai-setup.ts \"test/**/*.unit.ts\""
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"peerDependencies": {
"typescript": ">=2.8.0"
},
"files": [
"cjs",
"esm",
"src"
"dist",
"!dist/test",
"src",
"!*/tsconfig.{json,tsbuildinfo}"
],
"sideEffects": false,
"author": "Avi Vahl <avi.vahl@wix.com>",
Expand Down
6 changes: 6 additions & 0 deletions packages/robotrix/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist"
}
}
2 changes: 1 addition & 1 deletion packages/robotrix/test/cjs-to-esm-transformer.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ts from 'typescript';
import { expect } from 'chai';
import { createCjsToEsmTransformer } from '../src';
import { createCjsToEsmTransformer } from '@ts-tools/robotrix';

const cjsDef = `let exports = {}, module = { exports }`;
const cjsEsmExport = `export default module.exports`;
Expand Down
2 changes: 1 addition & 1 deletion packages/robotrix/test/dead-ifs-transformer.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import ts from 'typescript';
import { deadIfsTransformer } from '../src';
import { deadIfsTransformer } from '@ts-tools/robotrix';

describe('DeadIfsTransformer', () => {
const transformers: ts.CustomTransformers = { before: [deadIfsTransformer] };
Expand Down
2 changes: 1 addition & 1 deletion packages/robotrix/test/node-env-transformer.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { transpileModule } from 'typescript';
import { createNodeEnvTransformer } from '../src';
import { createNodeEnvTransformer } from '@ts-tools/robotrix';

describe('NodeEnvTransformer', () => {
it('replaces process.env.[PARAM] using provided dictionary', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/robotrix/test/react-dev-transformer.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import ts from 'typescript';
import { reactDevTransformer } from '../src';
import { reactDevTransformer } from '@ts-tools/robotrix';

describe('ReactDevTransformer', () => {
const transformers: ts.CustomTransformers = { before: [reactDevTransformer] };
Expand Down
2 changes: 1 addition & 1 deletion packages/robotrix/test/remap-imports-transformer.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import ts from 'typescript';
import { createRemapImportsTransformer } from '../src';
import { createRemapImportsTransformer } from '@ts-tools/robotrix';

describe('RemapImportsTransformer', () => {
const compilerOptions: ts.CompilerOptions = { target: ts.ScriptTarget.ES2017 };
Expand Down
12 changes: 12 additions & 0 deletions packages/robotrix/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/test",
"types": ["node", "mocha"]
},
"references": [
{
"path": "../src/tsconfig.json"
}
]
}
6 changes: 0 additions & 6 deletions packages/robotrix/tsconfig.build.json

This file was deleted.

15 changes: 6 additions & 9 deletions packages/transpile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
"name": "@ts-tools/transpile",
"version": "2.0.0",
"description": "TypeScript transpilation helpers.",
"main": "./cjs/index.js",
"types": "./cjs/index.d.ts",
"scripts": {
"clean": "rimraf ./cjs",
"prebuild": "yarn clean",
"build": "tsc -p tsconfig.build.json"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"peerDependencies": {
"typescript": ">=2.8.0"
},
"files": [
"cjs",
"src"
"dist",
"!dist/test",
"src",
"!*/tsconfig.{json,tsbuildinfo}"
],
"author": "Avi Vahl <avi.vahl@wix.com>",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions packages/transpile/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist"
}
}
10 changes: 0 additions & 10 deletions packages/transpile/tsconfig.build.json

This file was deleted.