aurelia / tools

Tools and utility functions used to build and develop Aurelia's libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate declaration "$"

JeroenVinke opened this issue · comments

We are trying to add dts-generation to this plugin, however we are getting an error:

events.js:141
      throw er; // Unhandled 'error' event
      ^
 TypeError: D:/Development/aurelia-kendoui-plugin/dist/aurelia-kendoui-plugin.js: Line 186: Duplicate declaration "$"
�[0m  184 | �[90m// };�[39m
  185 |
> 186 | �[36mimport�[39m $ from �[31m'jquery'�[39m�[1m;�[22m
      |        ^
  187 | �[36mimport�[39m �[31m'kendo-ui/js/kendo.button.min'�[39m�[1m;�[22m
  188 |
  189 | �[7m@�[27mcustomAttribute�[94m�[1m(�[22m�[39m�[31m'au-kendo-button'�[39m�[94m�[1m)�[22m�[39m�[0m
    at File.errorWithNode (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\transformation\file\index.js:489:13)
    at Scope.checkBlockScopedCollisions (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\scope\index.js:412:27)
    at Scope.<anonymous> (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\scope\index.js:594:18)
    at Scope.registerBinding (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\scope\index.js:608:8)
    at Scope.registerDeclaration (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\scope\index.js:537:14)
    at NodePath.Declaration (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\scope\index.js:83:36)
    at NodePath.call (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\path\context.js:56:28)
    at NodePath.visit (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\path\context.js:90:8)
    at TraversalContext.visitMultiple (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\context.js:108:16)
    at TraversalContext.visit (D:\Development\aurelia-kendoui-plugin\node_modules\babel-core\lib\traversal\context.js:146:19)

I have noticed that in the generated aurelia-kendoui-plugin.js, the following imports were not hoisted and were not deduplicated:

import $ from 'jquery';
import 'kendo-ui/js/kendo.autocomplete.min';

I think this is because these imports do not match the regex patterns.

I assume this is a very common use-case for plugins, and I hope that a fix will be provided for this :)

The workaround I've used (with success) is: aurelia-ui-toolkits@53cc9fe

Since the workaround is pretty ugly, I'm not going to submit this as a PR :)

@JeroenVinke could you test if your issue is fixed with version 0.1.20

@doktordirk thanks, i'll check

@doktordirk Seems to work fine, thanks! 👍