@loopback/build 7.0.1 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,54 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.1.0](https://github.com/loopbackio/loopback-next/compare/@loopback/build@8.0.1...@loopback/build@8.1.0) (2022-02-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * update @types/node to v12 ([65a09a4](https://github.com/loopbackio/loopback-next/commit/65a09a406e4865f774f97b58af9e616733b8b255))
12
+
13
+
14
+
15
+
16
+
17
+ ## [8.0.1](https://github.com/loopbackio/loopback-next/compare/@loopback/build@8.0.0...@loopback/build@8.0.1) (2022-01-11)
18
+
19
+ **Note:** Version bump only for package @loopback/build
20
+
21
+
22
+
23
+
24
+
25
+ # [8.0.0](https://github.com/loopbackio/loopback-next/compare/@loopback/build@7.0.2...@loopback/build@8.0.0) (2021-11-18)
26
+
27
+
28
+ ### Features
29
+
30
+ * drop support for Node.js v10 ([9bcbbb3](https://github.com/loopbackio/loopback-next/commit/9bcbbb358ec3eabc3033d4e7e1c22b524a7069b3))
31
+ * support Node.js v17 ([8d86c03](https://github.com/loopbackio/loopback-next/commit/8d86c03cb7047e2b1f18d05870628ef5783e71b2))
32
+ * upgrade to TypeScript 4.5.2 ([72ece91](https://github.com/loopbackio/loopback-next/commit/72ece91289ecfdfd8747bb9888ad75db73e8ff4b))
33
+
34
+
35
+ ### BREAKING CHANGES
36
+
37
+ * drop support for Node.js v10
38
+
39
+ Co-authored-by: Francisco Buceta <frbuceta@gmail.com>
40
+ Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
41
+
42
+
43
+
44
+
45
+
46
+ ## [7.0.2](https://github.com/loopbackio/loopback-next/compare/@loopback/build@7.0.1...@loopback/build@7.0.2) (2021-10-18)
47
+
48
+ **Note:** Version bump only for package @loopback/build
49
+
50
+
51
+
52
+
53
+
6
54
  ## [7.0.1](https://github.com/loopbackio/loopback-next/compare/@loopback/build@7.0.0...@loopback/build@7.0.1) (2021-09-16)
7
55
 
8
56
  **Note:** Version bump only for package @loopback/build
package/README.md CHANGED
@@ -94,6 +94,15 @@ Now you run the scripts, such as:
94
94
  | ------------------ | ------------------------------------------------------------------------------------------------- |
95
95
  | `--copy-resources` | Copy all non-typescript files from `src` and `test` to `outDir`, preserving their relative paths. |
96
96
 
97
+ - Using [`ttypescript`](https://github.com/cevek/ttypescript)
98
+
99
+ ### Stability: ⚠️Experimental⚠️
100
+
101
+ If you would like to use `ttypescript` and its availalbe plugins, you can
102
+ substitute `lb-tsc` with `lb-ttsc`, or pass the option
103
+ `lb-tsc --use-ttypescript`. If `ttypescript` is not installed, the default
104
+ TypeScript compiler `tsc` will be used instead.
105
+
97
106
  4. Run builds
98
107
 
99
108
  ```sh
@@ -34,8 +34,12 @@ function run(argv, options) {
34
34
 
35
35
  const packageDir = utils.getPackageDir();
36
36
 
37
- const compilerOpts = argv.slice(2);
37
+ const runnerName = argv[1];
38
38
 
39
+ const compilerOpts = argv.slice(2);
40
+ const runnerIsLbttsc = runnerName.includes('lb-ttsc');
41
+ const isUseTtscSet = utils.isOptionSet(compilerOpts, '--use-ttypescript');
42
+ const useTtsc = runnerIsLbttsc || isUseTtscSet;
39
43
  const isTargetSet = utils.isOptionSet(compilerOpts, '--target');
40
44
  const isOutDirSet = utils.isOptionSet(compilerOpts, '--outDir');
41
45
  const isProjectSet = utils.isOptionSet(compilerOpts, '-p', '--project');
@@ -44,12 +48,35 @@ function run(argv, options) {
44
48
  '--copy-resources',
45
49
  );
46
50
 
47
- // --copy-resources is not a TS Compiler option so we remove it from the
48
- // list of compiler options to avoid compiler errors.
51
+ let TSC_CLI = 'typescript/lib/tsc';
52
+ if (useTtsc) {
53
+ try {
54
+ require.resolve('ttypescript');
55
+ TSC_CLI = 'ttypescript/lib/tsc';
56
+ } catch (e) {
57
+ if (isUseTtscSet) {
58
+ console.error(
59
+ 'Error using the --use-ttypescript option - ttypescript is not installed',
60
+ );
61
+ } else {
62
+ console.error('Error using lb-ttsc - ttypescript is not installed');
63
+ }
64
+ process.exit(1);
65
+ }
66
+ }
67
+ debug(`Using ${TSC_CLI} to compile package`);
68
+
69
+ // --copy-resources and --use-ttypescript are not a TS Compiler options,
70
+ // so we remove them from the list of compiler options to avoid compiler
71
+ // errors.
49
72
  if (isCopyResourcesSet) {
50
73
  compilerOpts.splice(compilerOpts.indexOf('--copy-resources'), 1);
51
74
  }
52
75
 
76
+ if (isUseTtscSet) {
77
+ compilerOpts.splice(compilerOpts.indexOf('--use-ttypescript'), 1);
78
+ }
79
+
53
80
  let target;
54
81
  if (isTargetSet) {
55
82
  const targetIx = compilerOpts.indexOf('--target');
@@ -138,7 +165,7 @@ function run(argv, options) {
138
165
 
139
166
  const validArgs = validArgsForBuild(args);
140
167
 
141
- return utils.runCLI('typescript/lib/tsc', validArgs, {cwd, ...options});
168
+ return utils.runCLI(TSC_CLI, validArgs, {cwd, ...options});
142
169
  }
143
170
 
144
171
  /**
@@ -10,6 +10,9 @@
10
10
  // FIXME(bajtos) LB4 is not compatible with this setting yet
11
11
  "strictPropertyInitialization": false,
12
12
 
13
+ // https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables
14
+ "useUnknownInCatchVariables": false,
15
+
13
16
  "incremental": true,
14
17
 
15
18
  "lib": ["es2020"],
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@loopback/build",
3
3
  "description": "A set of common scripts and default configurations to build LoopBack 4 or other TypeScript modules",
4
- "version": "7.0.1",
4
+ "version": "8.1.0",
5
5
  "license": "MIT",
6
6
  "bin": {
7
7
  "lb-tsc": "./bin/compile-package.js",
8
+ "lb-ttsc": "./bin/compile-package.js",
8
9
  "lb-eslint": "./bin/run-eslint.js",
9
10
  "lb-prettier": "./bin/run-prettier.js",
10
11
  "lb-mocha": "./bin/run-mocha.js",
@@ -20,7 +21,7 @@
20
21
  "directory": "packages/build"
21
22
  },
22
23
  "engines": {
23
- "node": "^10.16 || 12 || 14 || 16"
24
+ "node": "12 || 14 || 16 || 17"
24
25
  },
25
26
  "scripts": {
26
27
  "test": "npm run mocha",
@@ -30,21 +31,21 @@
30
31
  "access": "public"
31
32
  },
32
33
  "dependencies": {
33
- "@loopback/eslint-config": "^11.0.1",
34
- "@types/mocha": "^9.0.0",
35
- "@types/node": "^10.17.60",
34
+ "@loopback/eslint-config": "^12.0.2",
35
+ "@types/mocha": "^9.1.0",
36
+ "@types/node": "^12.20.43",
36
37
  "cross-spawn": "^7.0.3",
37
- "debug": "^4.3.2",
38
- "eslint": "^7.32.0",
38
+ "debug": "^4.3.3",
39
+ "eslint": "^8.8.0",
39
40
  "fs-extra": "^10.0.0",
40
- "glob": "^7.1.7",
41
+ "glob": "^7.2.0",
41
42
  "lodash": "^4.17.21",
42
- "mocha": "^9.1.1",
43
+ "mocha": "^9.2.0",
43
44
  "nyc": "^15.1.0",
44
- "prettier": "^2.4.0",
45
+ "prettier": "^2.5.1",
45
46
  "rimraf": "^3.0.2",
46
- "source-map-support": "^0.5.20",
47
- "typescript": "~4.3.5"
47
+ "source-map-support": "^0.5.21",
48
+ "typescript": "~4.5.5"
48
49
  },
49
- "gitHead": "1df36bb1ee2e513d9e197bd6010c4cfb296d50b8"
50
+ "gitHead": "e16818ccb01edc0269ef6c45b022c5f1b67f852c"
50
51
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const assert = require('assert');
9
9
  const path = require('path');
10
+ const spawn = require('cross-spawn');
10
11
  const fs = require('fs-extra');
11
12
  const utils = require('../../bin/utils');
12
13
 
@@ -56,6 +57,30 @@ describe('build', /** @this {Mocha.Suite} */ function () {
56
57
  });
57
58
  });
58
59
 
60
+ describe('with --use-ttypescript', () => {
61
+ it('Returns an error if ttypescript is not installed', done => {
62
+ const childProcess = spawn(
63
+ process.execPath, // Typically '/usr/local/bin/node'
64
+ ['../../../bin/compile-package', '--use-ttypescript'],
65
+ {
66
+ env: Object.create(process.env),
67
+ },
68
+ );
69
+ let processOutput;
70
+ childProcess.stderr.on('data', m => {
71
+ processOutput = m.toString('ascii');
72
+ });
73
+ childProcess.on('close', code => {
74
+ assert.equal(code, 1);
75
+ assert.equal(
76
+ processOutput,
77
+ 'Error using the --use-ttypescript option - ttypescript is not installed\n',
78
+ );
79
+ done();
80
+ });
81
+ });
82
+ });
83
+
59
84
  it('honors tsconfig.build.json over tsconfig.json', () => {
60
85
  fs.writeJSONSync('tsconfig.build.json', {
61
86
  extends: '../../../config/tsconfig.common.json',