Skip to content

Unable to find module in node_modules only when targeting ES6, ES5 works fine #8189

@benlesh

Description

@benlesh

TypeScript Version: 1.8.10 and higher

Code

Actual code that causes the problem can be found on this issue: ReactiveX/rxjs#1637

# clone the repo
git clone [email protected]:ReactiveX/rxjs.git

# get PR branch
git fetch master pull/1637/head:pr-1637
git checkout pr-1637

# install dependencies (runs build, too, which will fail, but that's okay)
npm i

# try building the CJS version (success)
npm run build_cjs

# try building the ES6 version (failure)
npm run build_es6

The exact scripts being run are:

tsc typings/main/ambient/es6-shim/index.d.ts ./dist/cjs/src/Rx.ts ./dist/cjs/src/Rx.KitchenSink.ts ./dist/cjs/src/Rx.DOM.ts ./dist/cjs/src/add/observable/of.ts                             -m commonjs --sourceMap --outDir ./dist/cjs --target ES5 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors
tsc                                          ./dist/es6/src/Rx.ts ./dist/es6/src/Rx.KitchenSink.ts ./dist/es6/src/Rx.DOM.ts ./dist/es6/src/add/observable/of.ts                             -m es2015   --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors

Expected behavior:

Both build successfully.

Actual behavior:

Only the CJS build succeeds, the ES6 build fails:

11 import * as observableSymbol from 'symbol-observable';
                                     ~~~~~~~~~~~~~~~~~~~

dist/es6/src/Observable.ts(11,35): error TS2307: Cannot find module 'symbol-observable'.


16 import * as observableSymbol from 'symbol-observable';
                                     ~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/FromObservable.ts(16,35): error TS2307: Cannot find module 'symbol-observable'.


11 import * as observableSymbol from 'symbol-observable';
                                     ~~~~~~~~~~~~~~~~~~~

dist/es6/src/util/subscribeToResult.ts(11,35): error TS2307: Cannot find module 'symbol-observable'.


142 import * as observable from 'symbol-observable';
                                ~~~~~~~~~~~~~~~~~~~

dist/es6/src/Rx.ts(142,29): error TS2307: Cannot find module 'symbol-observable'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions