Skip to content

Commit

Permalink
Merge pull request #47 from njgheorghita/module-alias
Browse files Browse the repository at this point in the history
Replace module-alias with ttypescript
  • Loading branch information
njgheorghita committed Aug 31, 2020
2 parents c2da701 + 7c20e16 commit 516c449
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const plumber = require('gulp-plumber');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const typescript = require('typescript');
const typescript = require('ttypescript');
const dts = require('dts-bundle');
const typedoc = require('gulp-typedoc');
const eslint = require('gulp-eslint');
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethpm",
"version": "0.1.0-next.28",
"version": "0.1.0-next.29",
"description": "Javascript library for EthPM (EIPs 2678 / 1319)",
"main": "index.js",
"types": "main.d.ts",
Expand Down Expand Up @@ -62,6 +62,7 @@
},
"dependencies": {
"@types/lodash.isequal": "^4.5.5",
"@zerollup/ts-transform-paths": "^1.7.3",
"bn.js": "^4.11.8",
"debug": "^3.1.0",
"deep-equal": "^1.0.1",
Expand All @@ -73,9 +74,9 @@
"ipld-dag-pb": "^0.14.11",
"json-stable-stringify": "^1.0.1",
"lodash.isequal": "^4.5.0",
"module-alias": "^2.1.0",
"original-require": "^1.0.1",
"source-map-support": "^0.5.9",
"ttypescript": "^1.5.7",
"web3": "1.2.2"
},
"jest": {
Expand Down Expand Up @@ -108,9 +109,5 @@
],
"testEnvironment": "node",
"preset": "ts-jest"
},
"_moduleAliases": {
"ethpm": "dist",
"test": "dist/test"
}
}
9 changes: 8 additions & 1 deletion src/config/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ import * as config from './config';

const originalRequire: any = require("original-require");

const cleanPackagePath = (plugin: string): string => plugin.replace(
/^ethpm\//,
"../"
);

export function load<S>(plugin: config.ConfigValue<S>): config.Connector<S> {
const required = (typeof plugin === 'string')
? originalRequire(plugin)
? plugin.startsWith("ethpm/")
? require(cleanPackagePath(plugin))
: originalRequire(plugin)
: (typeof plugin === 'function')
? plugin
: (typeof plugin === 'object' && plugin.default)
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

require('source-map-support/register');
require('module-alias/register');

const { EthPM } = require('./ethpm');

Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"test/*": ["test/*"],
"ethpm": ["src"],
"ethpm/*": ["src/*"]
}
},
"plugins": [
{ "transform": "@zerollup/ts-transform-paths", "exclude": "*" }
]
},
"include": [
"src/**/*",
Expand Down

0 comments on commit 516c449

Please sign in to comment.