YuriGor / deepdash

eachDeep, filterDeep, findDeep, someDeep, omitDeep, pickDeep, keysDeep etc.. Tree traversal library written in Underscore/Lodash fashion
https://deepdash.io/
MIT License
272 stars 12 forks source link

Must use import to load ES Module #79

Closed vedantroy closed 3 years ago

vedantroy commented 3 years ago

When doing:

import * as __ from 'lodash'
import deepdash from 'deepdash-es'
const _ = deepdash(__)

I get the following error:

  5: import * as __ from 'lodash'      
   6: import deepdash from 'deepdash-es'
   7: const _ = deepdash(__)            

  Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/vedantroy/Desktop/clay/url-type-service/node_modules/deepdash-es/deepdash.js
  require() of ES modules is not supported.
  require() of /home/vedantroy/Desktop/clay/url-type-service/node_modules/deepdash-es/deepdash.js from /home/vedantroy/Desktop/clay/url-type-service/integration-tests/integration.lite.test.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
  Instead rename deepdash.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/vedantroy/Desktop/clay/url-type-service/node_modules/deepdash-es/package.json.
YuriGor commented 3 years ago

Hi, try this:

import * as __ from 'lodash-es'
import deepdash from 'deepdash-es'
const _ = deepdash(__)

if you use -es version of deepdash, use also -es version of lodash