Skip to content

Commit

Permalink
Fix issue with detecting AMD like imports (#4009)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk authored Feb 16, 2020
1 parent 503d8bf commit 98e585a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/js/compiler_sourcefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ export class SourceFile {
log(`Skipping imports for "${this.filename}"`);
return [];
}
const preProcessedFileInfo = ts.preProcessFile(this.sourceCode, true, true);
const preProcessedFileInfo = ts.preProcessFile(
this.sourceCode,
true,
this.mediaType === MediaType.JavaScript ||
this.mediaType === MediaType.JSX
);
this.processed = true;
const files = (this.importedFiles = [] as Array<[string, string]>);

Expand Down
6 changes: 6 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ itest!(_054_info_local_imports {
exit_code: 0,
});

itest!(js_import_detect {
args: "run --reload js_import_detect.ts",
output: "js_import_detect.ts.out",
exit_code: 0,
});

itest!(lock_write_fetch {
args:
"run --allow-read --allow-write --allow-env --allow-run lock_write_fetch.ts",
Expand Down
3 changes: 3 additions & 0 deletions cli/tests/js_import_detect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function define(_foo: string[]): void {}
define(["long"]);
console.log("ok");
1 change: 1 addition & 0 deletions cli/tests/js_import_detect.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok

0 comments on commit 98e585a

Please sign in to comment.