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

Fix broken dynamic import #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

steve-taylor
Copy link

@steve-taylor steve-taylor commented Apr 4, 2024

The dynamic import should have used await so it would destructure the imported module rather than the Promise returned by import('./src/cli/args.js').

Rather than add await, I converted it to a static import because the dynamic import seemed unnecessary.

@@ -14,7 +15,6 @@ export default async (args) => {

const results = args.results
if (!fs.existsSync(results)) {
const { showHelp } = import('./src/cli/args.js')
showHelp()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this fix, I see the error below when I run the following command (the test_logs directory exists, but foo.xml does not)

xunit-viewer -r test_logs/foo.xml

 TypeError: Cannot write private member to an object whose class did not declare it
    at O (/Users/williamwallace/.config/yarn/global/node_modules/yargs/build/index.cjs:1:3385)
    at showHelp (/Users/williamwallace/.config/yarn/global/node_modules/yargs/build/index.cjs:1:42722)
    at default (file:///Users/williamwallace/.config/yarn/global/node_modules/xunit-viewer/xunit-viewer.js:18:5)
    at file:///Users/williamwallace/.config/yarn/global/node_modules/xunit-viewer/bin/xunit-viewer.js:6:1
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:120:12)

@lukejpreston
Copy link
Owner

@steve-taylor could you elaborate on why it is broken?

@steve-taylor
Copy link
Author

could you elaborate on why it is broken?

@lukejpreston

TypeError: showHelp is not a function
    at default (file:///usr/local/lib/node_modules/xunit-viewer/xunit-viewer.js:18:5)
    at file:///usr/local/lib/node_modules/xunit-viewer/bin/xunit-viewer.js:6:1
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

The cause is explained here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants