Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ on:
schedule:
- cron: '0 6 * * 0' # weekly, on sundays

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
name: "Node ${{ matrix.node }} - ${{ matrix.os }}"
name: "Node ${{ matrix.node }} / TS: ${{ matrix.typescript }} - ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
timeout-minutes: 15

strategy:
fail-fast: false
matrix:
node: ['10', '12', '14']
node: ['12', '14', '16']
os: ['windows', 'ubuntu']
typescript: ['default']
include:
- node: 12
os: ubuntu
typescript: ~4.0.3
- node: 16
os: ubuntu
typescript: latest

steps:
- name: Ensure long path support
Expand All @@ -28,7 +42,27 @@ jobs:
- uses: volta-cli/action@v1
with:
node-version: ${{ matrix.node }}
- name: Cache
uses: actions/cache@v2
with:
path: node-modules
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-${{ matrix.node }}-
- name: install dependencies
run: yarn --frozen-lockfile
- run: |
git submodule init
git submodule update --depth 1
- name: Switch to alternate TS
if: matrix.typescript != 'default'
run: |
yarn upgrade typescript@${{ matrix.typescript }}
version=$(yarn tsc -v | grep Version | cut -d ' ' -f 2 | cut -d '.' -f 1,2)
cd vendor/typescript
git fetch origin release-${version} --depth 1
git checkout FETCH_HEAD
- run: yarn lint
- run: yarn test
- run: yarn test:no-update
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"link-self": "yarn link && yarn link broccoli-typescript-compiler",
"lint": "tslint --project tsconfig.json && tslint --project tests/tsconfig.json",
"prepare": "npm run build",
"test": "git submodule update --init && qunit dist/tests/*-test.js"
"test": "git submodule update --init && yarn test:no-update",
"test:no-update": "qunit dist/tests/*-test.js"
},
"dependencies": {
"broccoli-funnel": "^3.0.3",
Expand All @@ -45,7 +46,6 @@
"fs-tree-diff": "^2.0.1",
"heimdalljs": "0.3.3",
"md5-hex": "^3.0.1",
"typescript": "~4.0.3",
"walk-sync": "^2.1.0"
},
"devDependencies": {
Expand All @@ -65,11 +65,15 @@
"rollup-plugin-sourcemaps": "^0.5.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.13.0",
"tslint-plugin-prettier": "^1.3.0"
"tslint-plugin-prettier": "^1.3.0",
"typescript": "^4.5.5"
},
"engine": "node >= 10.0.0",
"peerDependencies": {
"typescript": "^4.0.3"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wagenet I may be wrong, but this not gonna make any difference as still will install typescript@4.0.3 by npm 7+

It's technically the same as replacing "typescript": "~4.0.3" with "typescript": "^4.0.3".

To truly decouple typescript version from broccoli-typescript-compiler, maybe you meant to make this

"peerDependencies": {
    "typescript": "*"
},
"peerDependenciesMeta": {
  "typescript": {
    "optional": true
  }
},

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeAstapov ah, you may be correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this means that, if a newer compatible version is installed, it will use that one. So this should be correct. I've been having some trouble validating it in practice either way.

},
"engine": "node >= 12.0.0",
"volta": {
"node": "10.20.1",
"node": "16.13.2",
"yarn": "1.22.4"
}
}
2 changes: 1 addition & 1 deletion scripts/build-expectations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function formatDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): st
return ts.formatDiagnostics(diagnostics, formatDiagnosticsHost);
}

const outputPath = path.resolve("tests/expectations");
const outputPath = path.resolve("tests/expectations", ts.versionMajorMinor);

rimraf.sync(outputPath);

Expand Down
12 changes: 11 additions & 1 deletion src/fs/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ import {
Resolution,
} from "../interfaces";

interface CodedError extends Error {
code: string;
}

function isCodedError(value: unknown): value is CodedError {
return (
value instanceof Error && typeof (value as CodedError).code === "string"
);
}

export function readFile(path: AbsolutePath): FileContent {
const buffer = readFileSync(path);
const hash = createHash("sha1");
Expand All @@ -34,7 +44,7 @@ export function stat(path: AbsolutePath): Stats | undefined {
try {
return statSync(path);
} catch (e) {
if (e.code === "ENOENT" || e.code === "EACCES") {
if (isCodedError(e) && (e.code === "ENOENT" || e.code === "EACCES")) {
return;
}
throw e;
Expand Down
3 changes: 2 additions & 1 deletion tests/cases-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { createBuilder, createTempDir, fromDir } from "broccoli-test-helper";
import typescript from "broccoli-typescript-compiler";
import * as fs from "fs";
import { versionMajorMinor } from "typescript";

// tests are output to dist/tests
const testCasesDir = fromDir(`${__dirname}/../../tests/cases`);
const testCases = fs.readdirSync(testCasesDir.path());
const expectationsDir = fromDir(`${__dirname}/../../tests/expectations`);
const expectationsDir = fromDir(`${__dirname}/../../tests/expectations/${versionMajorMinor}`);

// tslint:disable-next-line:only-arrow-functions
QUnit.module("plugin-cases", function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: {};
export default _default;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/a.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import B from "./b";
export default class A {
private b;
private name;
static create(name: string): A;
constructor(b: B, name: string);
hello(): void;
}
19 changes: 19 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/a.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/basic-resolutions/lib/a.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/b.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import C from "./c";
export default class B {
private c;
constructor(c: C);
hello(to: string): string;
}
13 changes: 13 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/b.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/basic-resolutions/lib/b.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/c.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class C {
shout(msg: any): string;
}
12 changes: 12 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/c.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/basic-resolutions/lib/c.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as A } from "./a";
export { default as B } from "./b";
export { default as C } from "./c";
export { default as CapitalizedComponent } from "./Components/CapitalizedComponent";
19 changes: 19 additions & 0 deletions tests/expectations/4.5/basic-resolutions/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/basic-resolutions/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/node-resolution/lib/count-down.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function countDown(c: number): void;
12 changes: 12 additions & 0 deletions tests/expectations/4.5/node-resolution/lib/count-down.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/node-resolution/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as countDown } from "./count-down";
13 changes: 13 additions & 0 deletions tests/expectations/4.5/node-resolution/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/expectations/4.5/node-resolution/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/expectations/4.5/web-worker/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
onmessage = function (evt) {
if (evt.data.cmd === "read") {
var reader = new FileReaderSync();
var file = evt.data.file;
var data = reader.readAsArrayBuffer(file);
postMessage({ cmd: "data", data: data }, [data]);
}
};
onerror = function (evt) {
postMessage({ cmd: "error", error: evt.error });
};
12 changes: 10 additions & 2 deletions tests/throw-on-error-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ QUnit.module("throwOnError", function({ beforeEach, afterEach }) {
try {
await output.build();
} catch (e) {
assertMatches(assert, e.message, /TS2322/);
assertMatches(
assert,
e instanceof Error ? e.message : String(e),
/TS2322/
);
}
}
);
Expand All @@ -99,7 +103,11 @@ QUnit.module("throwOnError", function({ beforeEach, afterEach }) {
try {
await output.build();
} catch (e) {
assertMatches(assert, e.message, /TS2322/);
assertMatches(
assert,
e instanceof Error ? e.message : String(e),
/TS2322/
);
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion vendor/typescript
Submodule typescript updated 10482 files
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2694,10 +2694,10 @@ type@^2.0.0:
resolved "https://registry.yarnpkg.com/type/-/type-2.0.0.tgz#5f16ff6ef2eb44f260494dae271033b29c09a9c3"
integrity sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==

typescript@~4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==
typescript@^4.5.5:
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

uglify-js@^3.1.4:
version "3.8.0"
Expand Down