You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a library called "gl-matrix" which I have the code and typings installed via npm. npm install gl-matrix npm install @types/gl-matrix
And it works fine in typescript with intellisense and all
root/src/index.js
import { mat4 } from "gl-matrix";
var aMatrix = mat4.create();
but the thing is, since browsers are now starting to natively support import statements, instead having to use require.js or something, I wanna do this natively, but I can't figure out how to get it to convert to the real import path of the javascript code for gl-matrix.
When it compiles I'd like it to point to root/node_modules/gl-matrix/dist/gl-matrix-min.js so I want it to emit this
import { mat4 } from "./../node_modules/gl-matrix/dist/gl-matrix-min.js";
var aMatrix = mat4.create();
I thought I could achieve this with the paths property of tsconfig, but apparently not.
tsconfig.json
Then how about a suggestion to have this sort of behaviour. I want to be able to use browser native importing (with typescript being able to find the correct typings file for it) rather than a 3rd party loader.
The native browser loader will not load CommonJS modules anyways (standard Node.js module format), so I don't think you are missing relative node_modules type resolution it simply won't work with most packages and there is still the very experimental .mjs format for Node. In particular the referenced import above is an UMD module, which is not loadable by the native module loader via the import syntax.
The issues of dealing with some level of compatibility with native loaders is covered under #13422.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
kitsonk commentedon Nov 11, 2017
This is not a support forum.
Questions should be asked at StackOverflow or on Gitter.im.
But, TypeScript does not re-write module paths, it only provides the tools to be able to resolve different paths under different loaders.
greghornby commentedon Nov 11, 2017
Then how about a suggestion to have this sort of behaviour. I want to be able to use browser native importing (with typescript being able to find the correct typings file for it) rather than a 3rd party loader.
kitsonk commentedon Nov 11, 2017
The native browser loader will not load CommonJS modules anyways (standard Node.js module format), so I don't think you are missing relative
node_modulestype resolution it simply won't work with most packages and there is still the very experimental.mjsformat for Node. In particular the referenced import above is an UMD module, which is not loadable by the native module loader via theimportsyntax.The issues of dealing with some level of compatibility with native loaders is covered under #13422.
typescript-bot commentedon Nov 29, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.