0

I need to create an alias for Hammer for my code. I have added paths in my tsconfig as shown below:

{
  "compilerOptions": {
    "declaration": true,
    "noImplicitAny": false  ,
    "noEmitOnError": true,
    "noUnusedLocals": false ,
    "noUnusedParameters": false ,
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "ES5",
    "outDir": "./lib",
    "lib": ["ES5", "ES2015.Promise", "DOM", "ES2015.Collection", "es2016"],
    "jsx": "react",
    "types": [],
    "baseUrl": ".",
    "paths": {
      "Hammer": ["hammerjs/hammer.js"]
    }
  },
  "include": ["typings/index.d.ts","src/*"]
}

But I am still getting an error when in geo.js, I have 'require(Hammer)'. What I am missing?

ERROR in ./~/geojs/geo.js
Module not found: Error: Can't resolve 'Hammer' in '/home/chaudhary/tools/jupyterlab/mydev/share/jupyter/lab/staging/node_modules/geojs'
 @ ./~/geojs/geo.js 3:27-44
 @ ./~/@jupyterlab/geojson-extension/lib/index.js
 @ ./build/index.out.js
Cœur
  • 37,241
  • 25
  • 195
  • 267
Aashish
  • 29
  • 2
  • Related to https://stackoverflow.com/questions/40443806/webpack-resolve-alias-does-not-work-with-typescript – Aashish Aug 22 '17 at 17:10
  • You need to configure your Paths for webpack as well: https://github.com/s-panferov/awesome-typescript-loader#advanced-path-resolution-in-typescript-20 – Thomas Devries Aug 22 '17 at 17:11
  • @ThomasDevries thanks. I am using ts-loader (https://github.com/TypeStrong/ts-loader), you can see Paths in my config above. – Aashish Aug 22 '17 at 18:20
  • I found an answer as in my case the calling program was creating its own webpack config, for now, I had to embed Hammer into GeoJS (removed Hammer as externals in webpack config). – Aashish Aug 23 '17 at 14:15

1 Answers1

0

I found an answer as in my case the calling program (JupyterLab) was creating a new webpack config everytime Jupyter lab build was invoked. For now, I had to embed Hammer into GeoJS (removed Hammer as externals in webpack config).

Aashish
  • 29
  • 2