@strapi/typescript-utils 4.2.0-beta.1 → 4.2.0-beta.4
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/lib/compile.js +2 -2
- package/lib/compilers/basic.js +7 -3
- package/lib/configs/server.json +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/resolve-outdir.js +17 -0
- package/package.json +2 -2
package/lib/compile.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
const compilers = require('./compilers');
|
|
4
4
|
const getConfigPath = require('./utils/get-config-path');
|
|
5
5
|
|
|
6
|
-
module.exports = async (srcDir, { watch = false } = {}) => {
|
|
6
|
+
module.exports = async (srcDir, { watch = false, configOptions = {} } = {}) => {
|
|
7
7
|
// TODO: Use the Strapi debug logger instead or don't log at all
|
|
8
8
|
console.log(`Starting the compilation for TypeScript files in ${srcDir}`);
|
|
9
9
|
|
|
10
10
|
const compiler = watch ? compilers.watch : compilers.basic;
|
|
11
11
|
const configPath = getConfigPath(srcDir);
|
|
12
12
|
|
|
13
|
-
compiler.run(configPath);
|
|
13
|
+
compiler.run(configPath, configOptions);
|
|
14
14
|
};
|
package/lib/compilers/basic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const ts = require('typescript');
|
|
4
|
+
const { merge } = require('lodash');
|
|
4
5
|
|
|
5
6
|
const reportDiagnostics = require('../utils/report-diagnostics');
|
|
6
7
|
const resolveConfigOptions = require('../utils/resolve-config-options');
|
|
@@ -9,15 +10,18 @@ module.exports = {
|
|
|
9
10
|
/**
|
|
10
11
|
* Default TS -> JS Compilation for Strapi
|
|
11
12
|
* @param {string} tsConfigPath
|
|
13
|
+
* @param {Object} configOptions
|
|
14
|
+
* @param {Array.<string>} configOptions.fileNames
|
|
15
|
+
* @param {Object} configOptions.options
|
|
12
16
|
*/
|
|
13
|
-
run(tsConfigPath) {
|
|
17
|
+
run(tsConfigPath, configOptions = {}) {
|
|
14
18
|
// Parse the tsconfig.json file & resolve the configuration options
|
|
15
19
|
const { fileNames, options, projectReferences } = resolveConfigOptions(tsConfigPath);
|
|
16
20
|
|
|
17
21
|
const program = ts.createProgram({
|
|
18
|
-
rootNames: fileNames,
|
|
22
|
+
rootNames: configOptions.fileNames ? configOptions.fileNames : fileNames,
|
|
19
23
|
projectReferences,
|
|
20
|
-
options,
|
|
24
|
+
options: merge(options, configOptions.options),
|
|
21
25
|
});
|
|
22
26
|
|
|
23
27
|
const emitResults = program.emit();
|
package/lib/configs/server.json
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const getConfigPath = require('./get-config-path');
|
|
|
6
6
|
const reportDiagnostics = require('./report-diagnostics');
|
|
7
7
|
const resolveConfigOptions = require('./resolve-config-options');
|
|
8
8
|
const formatHost = require('./format-host');
|
|
9
|
+
const resolveOutDir = require('./resolve-outdir');
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
isUsingTypeScript,
|
|
@@ -14,4 +15,5 @@ module.exports = {
|
|
|
14
15
|
reportDiagnostics,
|
|
15
16
|
resolveConfigOptions,
|
|
16
17
|
formatHost,
|
|
18
|
+
resolveOutDir,
|
|
17
19
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const resolveConfigOptions = require('./resolve-config-options');
|
|
4
|
+
const isUsingTypescript = require('./is-using-typescript');
|
|
5
|
+
|
|
6
|
+
const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
7
|
+
/**
|
|
8
|
+
* Gets the outDir value from config file (tsconfig)
|
|
9
|
+
* @param {string} dir
|
|
10
|
+
* @param {string | undefined} configFilename
|
|
11
|
+
* @returns {string | undefined}
|
|
12
|
+
*/
|
|
13
|
+
module.exports = async (dir, configFilename = DEFAULT_TS_CONFIG_FILENAME) => {
|
|
14
|
+
return (await isUsingTypescript(dir))
|
|
15
|
+
? resolveConfigOptions(path.join(dir, configFilename)).options.outDir
|
|
16
|
+
: undefined;
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/typescript-utils",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.4",
|
|
4
4
|
"description": "Typescript support for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"node": ">=12.22.0 <=16.x.x",
|
|
33
33
|
"npm": ">=6.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "5caff35a30e33b7a660eb946299f9e3d2d35b2b8"
|
|
36
36
|
}
|