hot-hook icon indicating copy to clipboard operation
hot-hook copied to clipboard

feat: consider missing import as dynamic

Open kerwanp opened this issue 5 months ago • 0 comments

Problem

As of today the DynamicImportChecker will look for an import with a specific specifier (the module specifier) meaning that imports using a dynamic value as specifier are not considered dynamic.

In the following example we are dynamically importing the modules present in the ./app/controllers folder. But they are not marked as dynamically imported by hot-hook.

  const pathes = await globby("./app/controllers", {
      absolute: true,
      expandDirectories: {
        extensions: ['ts', 'js', 'jsx'],
      },
    })

   for (const path of pathes) {
     await import(path)
   }

Solution

We should consider the dependency graph as a source of truth meaning that if we do not find any import for a given specifier in the parent we can consider that it is imported with a dynamic value.

kerwanp avatar Aug 25 '25 09:08 kerwanp