Skip to content

Duplicate emit when using amd-dependency and es6 ambient import #5021

Closed
@nycdotnet

Description

@nycdotnet

Hi,

I think that the ///<amd-dependency /> functionality exhibits odd behavior when combined with an ES6 import.

For example, this TypeScript code:

/// <amd-dependency name="jquery" path="/jquery/jquery.min.js" />
import 'jquery';

$('#myDiv').html('Hello');

emits as this JS when using AMD module mode:

define(["require", "exports", "/jquery/jquery.min.js", 'jquery'], function (require, exports, jquery) {
    $('#myDiv').html('Hello');
});

In the emitted JS, the string 'jquery' is included in the requirements for the module (causing an HTTP 404 error at runtime). My expectation would be that 'jquery' here would be considered the same as the 'jquery' inside the amd-dependency comment, so it would be de-duplicated and that only "/jquery/jquery.min.js" would be passed along to the emitted JS.

I can simply remove the ES6-style import and the emit works as expected.

Am I crazy on this?

I know this will probably be moot once #2338 hits.

Possibly related: #4004.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions