question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import statement in readme seems to be wrong

See original GitHub issue

The docs have this snippet:

// import update from 'react-addons-update';
import update from 'immutability-helper';

But the export looks like this:

module.exports = newContext();

Which works when you follow the docs on react-addons-update (seeing as it’s a drop-in replacement) for the import:

// var update = require('react-addons-update');
var update = require('immutability-helper');

But it doesn’t work when you use a bundler to transpile from ES6, because the docs’ ES6-style default import is misleading (this particular one is from my Webpack project):

Uncaught TypeError: immutability_helper_1.default is not a function

So should the interface be changed or the docs updated? I’m guessing the latter.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
seansfkelleycommented, Nov 8, 2016

@waldojeffers for libraries like this, you can always import * as update from 'immutability-helper', though depending on how exactly they are typed it may not actually work. I wrote the things for this library on DT, so I can assure you it works. 😃

@kolodny it’s still correct in javascript to import without default. It’s probably still worth changing the docs or adding that export statement you mention.

2reactions
seansfkelleycommented, Apr 16, 2016

Ah, looks like Babel tries to be clever and will see if it’s compiled by other Babel by looking for __esModule. I’m actually consuming this from Typescript, which doesn’t try to be clever (ignore the usage of define over require, it’s just doing that cause its in the browser).

Strictly speaking, the way it’s defined (namely, module.exports = ...) it should not be importable using default-import syntax, but Babel is trying to be helpful. Typescript explicitly doesn’t do this and Babel 6 stopped being clever about not emitting .default in some scenarios, so I think it’s probably not behavior that should be depended upon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My rst README is not formatted on pypi.python.org
I started a discussion on the distutils mailing list and found out that in-page links (i.e. #minimum-cash) are not allowed by the pypi...
Read more >
Relative urls in readme.md files only work half the time ... - Jira
I've confirmed that the problem with relative links only works if the readme is rendered at a specific commit. If it is rendered...
Read more >
eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >
Project Settings - ReadMe Documentation
Avoid importing versions that already exist in ReadMe. It's important to note that if there are clashing versions between those existing in ReadMe...
Read more >
ServiceDesk Plus readme, release notes, and version history
SD-101426 : In non-ESM setups, the Import SSL Certificate admin guide link present in help card is incorrect. SD-97178 : Unable to add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found