I am currently in the process of transitioning from using require
to using import
for all modules within my project. However, I have encountered some challenges with older npm modules that only provide instructions for require
.
For example, when it comes to 'isomorphic-fetch', I am having difficulty finding the correct way to utilize import
:
Works
require('isomorphic-fetch')
Fails
import 'isomporphic-fetch'
import Something from 'isomorphic-fetch'
// error Can't resolve 'isomporphic-fetch' from Project/src/js/
However, I have successfully converted to using import
with the es6-promise
module.
Works
require('es6-promise').polyfill()
Works
import Something from 'es6-promise'
Something.polyfill()