From be85b2077162cd36afccf043474356ef069afec8 Mon Sep 17 00:00:00 2001 From: Nick Gheorghita Date: Mon, 17 Aug 2020 17:10:20 -0500 Subject: [PATCH 1/3] Replace module-alias with ttypescript --- package.json | 7 ++----- src/index.ts | 1 - tsconfig.json | 5 ++++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 968b486..397ce40 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": { @@ -108,9 +109,5 @@ ], "testEnvironment": "node", "preset": "ts-jest" - }, - "_moduleAliases": { - "ethpm": "dist", - "test": "dist/test" } } diff --git a/src/index.ts b/src/index.ts index c5f661c..b36a4d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,6 @@ */ require('source-map-support/register'); -require('module-alias/register'); const { EthPM } = require('./ethpm'); diff --git a/tsconfig.json b/tsconfig.json index 1b5093f..9efb26e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,10 @@ "test/*": ["test/*"], "ethpm": ["src"], "ethpm/*": ["src/*"] - } + }, + "plugins": [ + { "transform": "@zerollup/ts-transform-paths", "exclude": "*" } + ] }, "include": [ "src/**/*", From daf49942d31392d52aef3360fbbcd0190e156bff Mon Sep 17 00:00:00 2001 From: Nick Gheorghita Date: Mon, 17 Aug 2020 17:10:20 -0500 Subject: [PATCH 2/3] Replace module-alias with ttypescript --- package.json | 9 +++------ src/index.ts | 1 - tsconfig.json | 5 ++++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 968b486..4d0a620 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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": { @@ -108,9 +109,5 @@ ], "testEnvironment": "node", "preset": "ts-jest" - }, - "_moduleAliases": { - "ethpm": "dist", - "test": "dist/test" } } diff --git a/src/index.ts b/src/index.ts index c5f661c..b36a4d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,6 @@ */ require('source-map-support/register'); -require('module-alias/register'); const { EthPM } = require('./ethpm'); diff --git a/tsconfig.json b/tsconfig.json index 1b5093f..9efb26e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,10 @@ "test/*": ["test/*"], "ethpm": ["src"], "ethpm/*": ["src/*"] - } + }, + "plugins": [ + { "transform": "@zerollup/ts-transform-paths", "exclude": "*" } + ] }, "include": [ "src/**/*", From 5bd04eda6fc9024dab38016ed308d553e491c70c Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Mon, 31 Aug 2020 15:26:56 -0400 Subject: [PATCH 3/3] Switch to using ttypescript in gulp ... 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 --- gulpfile.js | 2 +- src/config/loader.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b142509..6e17194 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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'); diff --git a/src/config/loader.ts b/src/config/loader.ts index fc6a833..d64f4b5 100644 --- a/src/config/loader.ts +++ b/src/config/loader.ts @@ -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(plugin: config.ConfigValue): config.Connector { const required = (typeof plugin === 'string') - ? originalRequire(plugin) + ? plugin.startsWith("ethpm/") + ? require(cleanPackagePath(plugin)) + : originalRequire(plugin) : (typeof plugin === 'function') ? plugin : (typeof plugin === 'object' && plugin.default)