diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c45d269..20ccd0c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ * Fixed `--override` to support `package-lock.json` with `lockfileVersion` 2 and 3. +### pack + +* Fixed `enact pack` to work with TypeScript 7 by skipping in-build type checking (`fork-ts-checker`), which requires the JavaScript API that TypeScript 7 no longer provides. +* Fixed `enact pack` to report errors thrown while preparing the build and exit with a non-zero status, rather than logging them as an uncaught exception and exiting successfully without producing any output. + +### serve + +* Fixed `enact serve` to report errors thrown while preparing the build and exit with a non-zero status. + ## 7.3.3 (July 7, 2026) ### transpile diff --git a/commands/pack.js b/commands/pack.js index cb937de1..c8a68141 100755 --- a/commands/pack.js +++ b/commands/pack.js @@ -329,11 +329,16 @@ function cli (args) { chalk = _chalk; import('strip-ansi').then(({default: _stripAnsi}) => { stripAnsi = _stripAnsi; - api(opts).catch(err => { - printErrorDetails(err, () => { - process.exit(1); + // Run api() inside the promise chain so that errors thrown synchronously while preparing the + // build (e.g. creating the webpack config) are reported and fail the process, rather than + // becoming an uncaught exception that bin/enact.js logs and then exits successfully. + Promise.resolve() + .then(() => api(opts)) + .catch(err => { + printErrorDetails(err, () => { + process.exit(1); + }); }); - }); }); }); } diff --git a/commands/serve.js b/commands/serve.js index 84619dd7..bbbac65e 100755 --- a/commands/serve.js +++ b/commands/serve.js @@ -368,11 +368,15 @@ function cli (args) { import('chalk').then(({default: _chalk}) => { chalk = _chalk; - api(opts).catch(err => { - // console.error(chalk.red('ERROR: ') + (err.message || err)); - console.log(err); - process.exit(1); - }); + // Run api() inside the promise chain so errors thrown synchronously are reported and fail the + // process instead of becoming an uncaught exception that bin/enact.js logs and swallows. + Promise.resolve() + .then(() => api(opts)) + .catch(err => { + // console.error(chalk.red('ERROR: ') + (err.message || err)); + console.log(err); + process.exit(1); + }); }); } diff --git a/config/webpack.config.js b/config/webpack.config.js index 18980f43..ba2a5040 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -39,6 +39,25 @@ const { } = require('@enact/dev-utils'); const createEnvironmentHash = require('./createEnvironmentHash'); +// TypeScript 7 and later no longer ship the classic JavaScript API (and have no `main` entry for +// `resolve` to find) that fork-ts-checker relies on, so in-build type checking is only available +// with TypeScript < 7. Source files are still transpiled by Babel regardless of the version; use +// `tsc` to type check with TypeScript 7+. +function hasTypeScriptJsApi () { + let version; + try { + version = require(path.resolve('node_modules/typescript/package.json')).version; + } catch (e) { + // TypeScript is not installed; let the type checker setup report that. + return true; + } + if (parseInt(version) >= 7) { + console.log(`TypeScript ${version} detected: skipping in-build type checking (run tsc separately).`); + return false; + } + return true; +} + // This is the production and development configuration. // It is focused on developer experience, fast rebuilds, and a minimal bundle. module.exports = function ( @@ -624,7 +643,7 @@ module.exports = function ( // and parses any to copy over any webOS meta assets at build time. new WebOSMetaPlugin({htmlPlugin: HtmlWebpackPlugin}), // TypeScript type checking - useTypeScript && + useTypeScript && hasTypeScriptJsApi() && new ForkTsCheckerWebpackPlugin({ async: !isEnvProduction, typescript: {