RTVision / esbuild-dynamic-import

Plugin for transform dynamic imports in esbuild
17 stars 5 forks source link

Handle dynamic imports with simple string concatenation instead of template strings #8

Open julian-schneider opened 1 year ago

julian-schneider commented 1 year ago

This plugin currently does not support dynamic import statements comprised of string concatenation instead of template strings.

As an example for this requirement, I currently need to bundle Elastic UI with my module. Their code base contains this dynamic import. More precisely, during the bundling process, the equivalent line 102 in their distribution is included. (Note that the missing .js file extension is discussed in #7.)

It would be nice if there was an option that allows parsing simple string concatenations. But precautions must be taken so that the plugin does not damage lines that are not actually dynamic imports, such as this one.

A starting point to achieve this may be using ESLint's prefer-template rule and the --fix command line option as a preprocessing step that transforms string concatenations to template strings.

kalvenschraut commented 1 year ago

Hey, been a bit busy.

I have been thinking that this plugin should use an AST tool to find the imports instead of regex which should resolve this issue. Will look into this during the upcoming weekend,. along with your other opened issue.

graham-atom commented 1 year ago

any news on this?