import statement in readme seems to be wrong
See original GitHub issueThe 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:
- Created 7 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.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 ofdefine
overrequire
, 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.