ttypescript-browser-like-import-transformer

A custom transformer that can be used with ttypescript to transform ts imports to browser style imports


Project maintained by Jack-Works Hosted on GitHub Pages — Theme by mattgraham

Home > config > PluginConfigs > folderImport

PluginConfigs.folderImport property

Resolve NodeJS style path ‘./x’ to ‘./x/index.js’

Signature:

folderImport?: boolean

Remarks

Resolve NodeJS style folder import to their correct path.

Not recommend because it never will become a Web standard.

Only open it when your codebase is not easy to migrate from Node specified behaviors.

Example

Source:

Filename: folder-import/index.ts

import './folder'

Filename: folder-import/folder/index.ts

export default 0
import '../f2'

Filename: folder-import/f2/index.ts

export {}

Filename: folder-import/f2/f2.ts

import './'

Filename: folder-import/f2/inner/f.ts

import '../'

Output:

Filename: folder-import/index.js

import "./folder/index.js";

Filename: folder-import/folder/index.js

export default 0;
import "../f2/index.js";

Filename: folder-import/f2/index.js

export {};

Filename: folder-import/f2/f2.js

import "./index.js";

Filename: folder-import/f2/inner/f.js

import "../index.js";