An open API service indexing awesome lists of open source software.

https://github.com/ofhouse/ncc-bug-esmoduleinterop

Documents a discrepancy between JavaScript and TypeScript bundles when using esModuleInterop
https://github.com/ofhouse/ncc-bug-esmoduleinterop

Last synced: about 1 month ago
JSON representation

Documents a discrepancy between JavaScript and TypeScript bundles when using esModuleInterop

Awesome Lists containing this project

README

        

# `@zeit/ncc` bug with `esModuleInterop=true`

This repository is a reproduction of a bug with the ncc compiler:

## TypeScript (`esModuleInterop: false`)

This is the normal setting which includes the required asset `test.txt`

### Files

```ts
// tsconfig.json
{
"compilerOptions": {
"esModuleInterop": false
}
}

import * as fs from 'fs';
import * as path from 'path';

const file = fs.readFileSync(path.join(__dirname, 'test.txt'));
console.log(file);
```

### Output

```sh
index.js
test.txt
```

## TypeScript (`esModuleInterop: true`)

### Files

```ts
// tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true
}
}

import * as fs from 'fs';
import * as path from 'path';

const file = fs.readFileSync(path.join(__dirname, 'test.txt'));
console.log(file);
```

### Output

```sh
index.js
```