Skip to content

Commit

Permalink
Remove esm module dependency. Fixes #145.
Browse files Browse the repository at this point in the history
  • Loading branch information
kofrasa committed Jul 11, 2020
1 parent b483ba6 commit eddc51d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mingo",
"version": "3.0.2",
"description": "JavaScript implementation of MongoDB query language",
"main": "index.js",
"main": "./lib/index.js",
"module": "./lib/index.js",
"typings": "./lib/index.d.ts",
"scripts": {
Expand All @@ -28,11 +28,9 @@
"README.md",
"CHANGELOG.md"
],
"dependencies": {
"esm": "3.2.25"
},
"devDependencies": {
"codecov": "3.7.0",
"esm": "3.2.25",
"lodash": "4.17.19",
"nyc": "15.1.0",
"perf_hooks": "0.0.1",
Expand Down
11 changes: 1 addition & 10 deletions prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ const LIB_DIR = path.resolve('lib')

const CMD = process.argv.slice(2).join(' ')

const MAIN_JS_FILE = 'main.js'
const MAIN_JS_DATA = [
'require = require("esm")(module/*, options*/)',
'module.exports = require("./index.js")'
].join('\n')

// files to cleanup to avoid packing
const CLEANUP_FILES = [
'node_modules',
Expand Down Expand Up @@ -59,11 +53,8 @@ function prepare() {
'**/*.ts'
])

// write main entry files using esm
fs.writeFileSync(path.join(LIB_DIR, MAIN_JS_FILE), MAIN_JS_DATA)

// override entry files
packageJson.main = MAIN_JS_FILE
packageJson.main = 'index.js'
packageJson.module = 'index.js'
packageJson.typings = 'index.d.ts'

Expand Down
5 changes: 3 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ export function resolve(obj: object | any[], selector: string, options?: Resolve
if (i === 0 && depth > 0) break

depth += 1
path = path.slice(i)
// only look at the rest of the path
let subpath = path.slice(i)
value = value.reduce<any[]>((acc: any[], item: any) => {
let v = resolve2(item, path)
let v = resolve2(item, subpath)
if (v !== undefined) acc.push(v)
return acc
}, [])
Expand Down

0 comments on commit eddc51d

Please sign in to comment.