Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Known issues with NPM modules

Victor edited this page Jul 14, 2016 · 18 revisions

Bugs / unexpected behavior (with workaround)

phantomjs-prebuilt

  • PhantomJS (which runs our unit tests) has very poor support for ES5. For example, Array.find() will fail.
    workaround: include a polyfill in your test/index.ts entry file.

typescript

  • Libraries that use the export = syntax for exporting don't work in Typescript
    workaround: add "allowSyntheticDefaultImports": true to your tsconfig.json and import your libary using the syntax import * as name from 'some-npm-module'
  • The awesome-typescript-loader used in webpack builds and tests cannot correctly handle the const enum inlining, so the "preserveConstEnums" should be set to true. We want to have them preserved anyways so consumers of the modules can import and use those enums.

sinon

Sinon is not in our boilerplate by default but we will often include it for detecting function calls in unit tests.

  • Sinon does not work well with webpack
    workaround: use the sinon 2.0.0 prerelease

Bugs / unexpected behavior (no workaround yet)

karma-remap-istanbul

  • karma-remap-istanbul (for source mapping in our test coverage report) fails on the first run with the following message:
    WARN [reporter.remap-istanbul]: Could not find any specified files, exiting without doing anything.
    When the output files are already there the error will disappear on the second run.
    See: https://github.com/marcules/karma-remap-istanbul/issues/3

Other tips/tricks

Typings

Typings have different sources for definitions. By default it fetches them from its own npm registry: https://github.com/typings/registry/tree/master/npm.

You could change source: typings install dt~[definition-name] In this case Typings will fetch the latest definition file numbered version from defenetely typed. Sometimes defenetely typed is not consistent with version numbers, keeping the lastest version without any version number at all like lodash.d.ts instead of lodash-4.0.0.d.ts. In these cases, if you want to load the latest updated definition file you need to specify a version number 0.0.0 like: typings install dt~[definition-name]@0.0.0 (for eg: typings install [email protected])

Clone this wiki locally