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

add /*wakaru:missing*/ annotations to imports from missing modules/files #77

Closed
0xdevalias opened this issue Dec 18, 2023 · 5 comments · Fixed by #90
Closed

add /*wakaru:missing*/ annotations to imports from missing modules/files #77

0xdevalias opened this issue Dec 18, 2023 · 5 comments · Fixed by #90
Labels
enhancement New feature or request

Comments

@0xdevalias
Copy link

0xdevalias commented Dec 18, 2023

I was just testing the new webcrack web IDE (Ref), and noticed that they annotate the unminified source to explicitly mention when a module being imported from is missing with /*webcrack:missing*/. This would be a cool feature for wakaru to support as well.

You can see the full context of how I got to this unminified step on the issue I opened there (Ref), using this minified code (Ref), but here is what the annotation looks like in that unminified code:

webcrack's 180.js with the /*webcrack:missing*/ annotation:

require.d(exports, {
  Z: function () {
    return a;
  }
});
var r = require( /*webcrack:missing*/"./35250.js");
// ..snip..

Compared to wakaru's unminified module-180.js without it:

const { jsx } = require(35250);

// ..snip..

export default {
  Z: a,
};
@pionxzh
Copy link
Owner

pionxzh commented Dec 18, 2023

I have been bothered by it for a while too 😄 My another idea on this would be to create a missing-module-35250.js empty file as the placeholder. So that we can still convert them to ESM. I'm not sure if this is the best solution or if this is good in a typical workflow.

@0xdevalias
Copy link
Author

My another idea on this would be to create a missing-module-35250.js empty file as the placeholder. So that we can still convert them to ESM. I'm not sure if this is the best solution or if this is good in a typical workflow.

@pionxzh For a lot of my usages, I think that would end up creating more 'noise' than 'value', so if that were a feature you implemented, I think it would be best if it was optional/controllable via settings/a CLI flag/similar.

@pionxzh
Copy link
Owner

pionxzh commented Dec 30, 2023

I see. No worry. Then we can do the annotations first,

@pionxzh
Copy link
Owner

pionxzh commented Dec 30, 2023

Done with

const foo = require(9527/* wakaru:missing */);

@0xdevalias
Copy link
Author

Done

@pionxzh Thanks! Just gave this a go, works well :) 🎉

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

Successfully merging a pull request may close this issue.

2 participants