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: More info about dynamic imports #97

Closed
Kolobok12309 opened this issue Oct 11, 2022 · 1 comment
Closed

feat: More info about dynamic imports #97

Kolobok12309 opened this issue Oct 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Kolobok12309
Copy link

For example new props
isStatic: boolean - this import can changes or it static string
staticSpecifier: string or specifier: string - if isStatic: true it can be useful

My case for this props, i write small webpack loader for add some query params(?foo=bar) to some imports(doesn't matter static or dynamic)

Currently code that i use

const removeComments = text => text
  .replace(/\/\*.*\*\//gm, '')
  .replace(/\/\/.*\n/gm, '');

const isStaticDynamicImport = (expression) => {
  const normalized = removeComments(expression);

  return (normalized.startsWith('\'') && normalized.endsWith('\''))
    || (normalized.startsWith('"') && normalized.endsWith('"'));
};

// Not very stable i think
const getStaticSpecifier = (expression) => 
  removeComments(expression).slice(1, -1);
@danielroe danielroe added the enhancement New feature or request label Oct 11, 2022 — with Volta.net
@pi0
Copy link
Member

pi0 commented Jan 11, 2024

Hi dear @Kolobok12309 indeed it is sometimes handy to have more information off the import/exorts. Unfrounatly currently it is hard as we rely on Regex based parser.

With #219, we might be able to do that. I am closing this issue to track from single place. BTW thanks for suggestion 👍🏼

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
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

No branches or pull requests

3 participants