@@ -158,11 +158,12 @@ async function loadDTS(specifier: string): Promise<Lib[]> {
158158 if ( ! filePath . startsWith ( 'node_modules' ) ) {
159159 // Load every common typedef into the common module
160160 let content = await fetchFile ( `${ commonSpecifier } ${ filePath } ` ) ;
161- content = content . replace ( / \* + @ ( .+ ?) \* \/ / gs, '*/' ) ;
162- console . log ( content ) ;
163- results . push ( {
164- content : `declare module '@openfn/language-common' { ${ content } }` ,
165- } ) ;
161+ if ( ! content . startsWith ( '<!DOCTYPE html>' ) ) {
162+ content = content . replace ( / \* + @ ( .+ ?) \* \/ / gs, '*/' ) ;
163+ results . push ( {
164+ content : `declare module '@openfn/language-common' { ${ content } }` ,
165+ } ) ;
166+ }
166167 }
167168 }
168169 }
@@ -176,6 +177,13 @@ async function loadDTS(specifier: string): Promise<Lib[]> {
176177 for await ( const filePath of fetchDTSListing ( specifier ) ) {
177178 if ( ! filePath . startsWith ( 'node_modules' ) ) {
178179 let content = await fetchFile ( `${ specifier } ${ filePath } ` ) ;
180+ if ( content . match ( / < ! d o c t y p e h t m l > / i) ) {
181+ continue ;
182+ }
183+ // Convert relative paths
184+ content = content
185+ . replace ( / f r o m ' \. \/ / g, `from '${ name } /` )
186+ . replace ( / i m p o r t ' \. \/ / g, `import '${ name } /` ) ;
179187
180188 // Remove js doc annotations
181189 // this regex means: find a * then an @ (with 1+ space in between), then match everything up to a closing comment */
@@ -186,9 +194,6 @@ async function loadDTS(specifier: string): Promise<Lib[]> {
186194
187195 // Import the index as the global namespace - but take care to convert all paths to absolute
188196 if ( fileName === 'index' || fileName === 'Adaptor' ) {
189- content = content . replace ( / f r o m ' \. \/ / g, `from '${ name } /` ) ;
190- content = content . replace ( / i m p o r t ' \. \/ / g, `import '${ name } /` ) ;
191-
192197 // It turns out that "export * as " seems to straight up not work in Monaco
193198 // So this little hack will refactor import statements in a way that works
194199 content = content . replace (
@@ -218,6 +223,7 @@ async function loadDTS(specifier: string): Promise<Lib[]> {
218223 // This is basically a hack to work around https://github.com/OpenFn/lightning/issues/2641
219224 // If we find a types.d.ts, append it to every other file
220225 adaptorDefs = adaptorDefs . map ( def => def . replace ( '{{$TYPES}}' , types ) ) ;
226+ console . log ( adaptorDefs ) ;
221227
222228 results . push (
223229 ...adaptorDefs . map ( content => ( {
0 commit comments