RTVision / esbuild-dynamic-import

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

Allow dynamically importing .js files, without explicitly giving the file extension #7

Open julian-schneider opened 1 year ago

julian-schneider commented 1 year ago

Since the .js file extension is frequently omitted in import statements, it would be nice if this plugin supported this.

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 use of simple string concatenation instead of template strings is discussed in #8.)

By adding an empty string to the transformExtensions parameter, this plugin recognizes Elastic UI's dynamic import statement and adds the target files to the produced ImportMap, but the ImportMap only contains keys with the file extension.