Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace module-alias with ttypescript #47

Merged
merged 5 commits into from
Aug 31, 2020

Conversation

njgheorghita
Copy link
Contributor

No description provided.

@njgheorghita
Copy link
Contributor Author

@gnidan I spent some time trying to remove module-alias in favor of ttypescript as we discussed. I wasn't able to get very far past the basic install code. As expected, tests here and in truffle worked fine locally, but are failing in ci over in the truffle pr. If you have some time to get into it or point me in the right direction, I can dig a little deeper tomorrow.

@gnidan
Copy link
Contributor

gnidan commented Aug 18, 2020

I'll be in meetings for much of the workday today, but I'll put this on my list for afterwards.

In the meantime, can you go into the ethpm.js source directory, do a build, and then run:

$ node
> require(".")

and see what happens?

@njgheorghita
Copy link
Contributor Author

njgheorghita commented Aug 18, 2020

Nice, yeah I've been playing around with this and am left scratching my head.

  1. cd into /Users/nickgheorghita/ethereum/ethpm.js - and run npm run build
  2. cd into ethpm.js/dist - and run node --experimental-repl-await
  3. looking good so far
> require.resolve('.')
'/Users/nickgheorghita/ethereum/ethpm.js/dist/index.js'
> const { EthPM } = require(".");
undefined
  1. This is where i'm left confused
> await EthPM.configure({manifest: "ethpm/manifests/v3"}).connect({})
{ Error: Cannot find module 'ethpm/manifests/v3'
    at Object.configure (/Users/nickgheorghita/ethereum/src/ethpm.ts:39:12)
    at new map (/Users/nickgheorghita/node_modules/src/session/session.ts:20:10)
    at Array.map (<anonymous>)
    at load (/Users/nickgheorghita/node_modules/src/session/session.ts:21:29)
    at Object.originalRequire [as load] (/Users/nickgheorghita/node_modules/src/config/loader.ts:11:7)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) code: 'MODULE_NOT_FOUND' }

I can't figure out why the stack trace is 1) running typescript and 2) jumping around to node_modules/ directories in all kinds of locations. I even went as far to yank out the usage of the original-require library - yet, it ends up making a call to the library. It seems like I'm missing something fundamental about how the code in the dist/ folder is executed? For example - the top line of the stack trace points towards a file that doesn't exist on my machine....

@gnidan
Copy link
Contributor

gnidan commented Aug 18, 2020

Ah right, for this:

Error: Cannot find module 'ethpm/manifests/v3'

The problem is that, now that module-alias is gone, nothing tells Node's runtime how to find that module name. I think the solution here requires looking for ethpm/(.*) in configure, and changing that to ethpm/dist/src/\1 (or is it ethpm/dist/lib/\1? Whatever; convert it to the real path)

g. nicholas d'andrea and others added 3 commits August 31, 2020 15:26
... and also update configuring EthPM to use internal EthPM packages

- Use originalRequire() for non-internal module configurations
- Use regular require() for loading EthPM.js internals, replacing
  user-provided absolute paths with project-relative versions
Switch to using ttypescript in gulp
@njgheorghita njgheorghita merged commit 516c449 into ethpm:master Aug 31, 2020
@njgheorghita njgheorghita deleted the module-alias branch August 31, 2020 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants