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
With "moduleResolution": "node" compiler option, the import paths in JavaScript output for 'outDir' and 'outFile' options differs. I expected to see that the path of import { Rectangle } from './Shapes'; transforms to './Shapes/index'. However, I see '/index' at the end of Rectangle import path only if I use the 'outFile' option, not 'outDir'. Is this behavior expected or it is a bug in the typescript compiler?
TypeScript Version: 2.5.0
Code
/* tsconfig.json */{"compilerOptions": {"module": "system",// Or any other"moduleResolution": "node","outDir": "./dist",//"outFile": "./dist.js",},"include": ["lib/**/*.ts"]}
/* /dist/Drawer.js (outDir) */// system:System.register(["./Shapes/index"],function(exports_1,context_1){// or amd:define(["require","exports","./Shapes/index"],function(require,exports,Shapes_1){// or commonjs/umd:varShapes_1=require("./Shapes/index");// or es6/es2015/esnext:import{Rectangle}from'./Shapes/index';
/* /dist.js (outFile) */// system:System.register("Drawer",["Shapes/index"],function(exports_3,context_3){// or amd:define("Drawer",["require","exports","Shapes/index"],function(require,exports,Shapes_1){
Actual behavior:
/* /dist/Drawer.js (outDir). There aren't '/index' at the end of import paths. */// system:System.register(["./Shapes"],function(exports_1,context_1){// or amd:define(["require","exports","./Shapes"],function(require,exports,Shapes_1){// or commonjs/umd:varShapes_1=require("./Shapes");// or es6/es2015/esnext:import{Rectangle}from'./Shapes';
/* /dist.js (outFile). Identical to the one we expect. */// system:System.register("Drawer",["Shapes/index"],function(exports_3,context_3){// or amd:define("Drawer",["require","exports","Shapes/index"],function(require,exports,Shapes_1){
The text was updated successfully, but these errors were encountered:
The compiler should not be rewriting the imported module path regardless of whether or not you are using --moduleResolution node and regardless of whether you are using --ourDir or --outFile.
If you are using SystemJS, you need to specify that Shapes uses the index file convention popularized by Node.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
wrager
changed the title
Problem when using 'index.ts' with 'outDir' and 'node' module relosution
Problem when using 'index.ts' with 'outDir' and 'node' module resolution
Sep 27, 2017
With "moduleResolution": "node" compiler option, the import paths in JavaScript output for 'outDir' and 'outFile' options differs. I expected to see that the path of
import { Rectangle } from './Shapes';
transforms to './Shapes/index'. However, I see '/index' at the end ofRectangle
import path only if I use the 'outFile' option, not 'outDir'. Is this behavior expected or it is a bug in the typescript compiler?TypeScript Version: 2.5.0
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: