@@ -56,12 +56,19 @@ const parseConfigurationFile = async (configurationPath) => {
5656 case '.ts' :
5757 case '.mts' : {
5858 try {
59- const { createJiti } = require ( 'jiti' ) ;
60- const jiti = createJiti ( null , { interopDefault : true } ) ;
59+ // const { createJiti } = require('jiti');
60+ // const jiti = createJiti(null, { interopDefault: true });
61+ // const content = await jiti.import(configurationPath, { default: true });
6162
62- const content = await jiti . import ( configurationPath , { default : true } ) ;
63+ /**
64+ * Jiti does not support `tsconfig.paths`, so we need to use tsx to load the configuration file.
65+ * @see https://github.com/unjs/jiti/issues/373
66+ * @see https://tsx.is/dev-api/tsx-require
67+ */
68+ const tsx = require ( 'tsx/cjs/api' ) ;
69+ const content = tsx . require ( configurationPath , __filename ) ;
6370
64- return content ;
71+ return content . default ?? content ;
6572 } catch ( error ) {
6673 throw new ServerlessError (
6774 `Cannot parse "${ path . basename ( configurationPath ) } ": Initialization error: ${
@@ -145,6 +152,7 @@ module.exports = async (configurationPath) => {
145152 let configuration = await parseConfigurationFile ( configurationPath ) ;
146153
147154 if ( ! isPlainObject ( configuration ) ) {
155+ console . log ( 'configuration' , configuration ) ;
148156 throw new ServerlessError (
149157 `Invalid configuration at "${ path . basename ( configurationPath ) } ": Plain object expected` ,
150158 'INVALID_CONFIGURATION_EXPORT'
0 commit comments