Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Not working with nodegit #206

Closed
raine opened this issue Jan 2, 2018 · 11 comments
Closed

Not working with nodegit #206

raine opened this issue Jan 2, 2018 · 11 comments
Labels

Comments

@raine
Copy link

raine commented Jan 2, 2018

Getting this with nodegit:

% node
> require("@std/esm", { cjs: true, esm: 'js' })
@std/esm enabled
> import * as nodegit from 'nodegit'
Error [ERR_MISSING_MODULE]: Cannot find module ./annotated_commit
% node
> require('nodegit')
{ StatusFile: [Function: StatusFile],
  Enums:
   { CVAR: { FALSE: 0, TRUE: 1, INT32: 2, STRING: 3 },
     DIRECTION: { FETCH: 0, PUSH: 1 },
     FEATURE: { THREADS: 1, HTTPS: 2, SSH: 4, NSEC: 8 },
     IDXENTRY_EXTENDED_FLAG:
      { IDXENTRY_INTENT_TO_ADD: 8192,
        IDXENTRY_SKIP_WORKTREE: 16384,
        IDXENTRY_EXTENDED2: 32768,
        S: 24576,
        IDXENTRY_UPDATE: 1,
        IDXENTRY_REMOVE: 2,
        IDXENTRY_UPTODATE: 4,
        IDXENTRY_ADDED: 8,
        IDXENTRY_HASHED: 16,
        IDXENTRY_UNHASHED: 32,
        IDXENTRY_WT_REMOVE: 64,
        IDXENTRY_CONFLICTED: 128,
        IDXENTRY_UNPACKED: 256,
        IDXENTRY_NEW_SKIP_WORKTREE: 512 },
     INDXENTRY_FLAG: { IDXENTRY_EXTENDED: 16384, IDXENTRY_VALID: 32768 } },
  DiffLine:
   { [Function: DiffLine]
     getSelfFreeingInstanceCount: [Function: getSelfFreeingInstanceCount],
     getNonSelfFreeingConstructedCount: [Function: getNonSelfFreeingConstructedCount] },
  version: '0.20.3',
  Promise: [Function: Promise] }

Not sure if this is a problem with @std/esm or nodegit, but might be something worth looking into.

@jdalton
Copy link
Member

jdalton commented Jan 2, 2018

Hi @raine!

Thanks for reporting. I'll dig in shortly.

@raine
Copy link
Author

raine commented Jan 2, 2018

I found this workaround:

index.js

require('nodegit')
require = require("@std/esm")(module)
require('./src/main.js')

main.js

// works because it was required once before @std/esm was initialized
import nodegit from 'nodegit'

@jdalton
Copy link
Member

jdalton commented Jan 2, 2018

I found the issue:

nodegit is looking for the error code "MODULE_NOT_FOUND" and we are providing the new code of "ERR_MISSING_MODULE". We should use the old code for CJS.

I'll think on filing an issue with nodegit to support both though as Node may migrate to the new code.

@raine
Copy link
Author

raine commented Jan 3, 2018

Thanks @jdalton!

@jdalton
Copy link
Member

jdalton commented Jan 6, 2018

@std/esm v0.19.0 is released 🎉

@raine
Copy link
Author

raine commented Jan 19, 2018

Hmm, I am getting this on v0.19.7 also. Was it supposed to remedy this?

> require("@std/esm", { cjs: true, esm: 'js' })
@std/esm enabled
> import * as nodegit from 'nodegit'
project/node_modules/nodegit/dist/nodegit.js:1
Error [ERR_MISSING_MODULE]: Cannot find module file:///project/annotated_commit
    at importExtension (/project/node_modules/nodegit/dist/nodegit.js:822:5)
    at Object.<anonymous> (/project/node_modules/nodegit/dist/nodegit.js:844:1)

@jdalton
Copy link
Member

jdalton commented Jan 19, 2018

It should be, this regression looks like a job for a more thorough scenario test!
Thanks for pinging. I'll patch it by today.

Update:

@raine I can't seem to repro this with v0.19.7.
Have you tried clearing your node_modules folder just in case?

@raine
Copy link
Author

raine commented Jan 20, 2018

Looks like it occurs when package.json contains "@std/esm": {"cjs": true, "esm": "js"}, and works when it doesn't. It's strange because I'm running require("@std/esm", { cjs: true, esm: 'js' }) where options are the same.

https://github.com/raine/std-esm-nodegit

@jdalton
Copy link
Member

jdalton commented Jan 20, 2018

Ah okay!

Update:

Patches 9fa22a7, 56f1597, 428f266

@jdalton
Copy link
Member

jdalton commented Jan 28, 2018

v0.20.0 is released 🎉

@raine
Copy link
Author

raine commented Jan 29, 2018

Just tried the latest version and it works. Thanks again, @jdalton.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants