Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow all file extension inputs (including .jsx) #294

Merged
merged 2 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/node-file-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export async function nodeFileTrace(files: string[], opts: NodeFileTraceOptions
await Promise.all(files.map(async file => {
const path = resolve(file);
await job.emitFile(path, 'initial');
if (path.endsWith('.js') || path.endsWith('.cjs') || path.endsWith('.mjs') || path.endsWith('.node') || job.ts && (path.endsWith('.ts') || path.endsWith('.tsx'))) {
return job.emitDependency(path);
}
return undefined;
return job.emitDependency(path);
}));

const result: NodeFileTraceResult = {
Expand Down
3 changes: 3 additions & 0 deletions test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ for (const { testName, isRoot } of unitTests) {
let inputFileNames = ["input.js"];
let outputFileName = "output.js";

if (testName === "jsx-input") {
inputFileNames = ["input.jsx"];
}
if (testName === "tsx-input") {
inputFileNames = ["input.tsx"];
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/jsx-input/dep.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const dep = <h1>dep</h1>
3 changes: 3 additions & 0 deletions test/unit/jsx-input/input.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { readFileSync } from 'fs';

readFileSync(__dirname + '/dep.jsx');
4 changes: 4 additions & 0 deletions test/unit/jsx-input/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"test/unit/jsx-input/dep.jsx",
"test/unit/jsx-input/input.jsx"
]