5

e.g:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div id="app"> {{ message }} </div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js'></script> <script src="app.js"></script> </body> </html> 

app.ts :

import { Vue } from "vue/types/vue"; let vue = new Vue({ el:"#app", data:{ text:"hello world" } }) 

after cmd tsc it'll generate below js

"use strict"; exports.__esModule = true; var vue_1 = require("vue/types/vue"); var vue = new vue_1.Vue({ el: "#app", data: { text: "hello world" } }); 

My Expected

I hope to disable generate "exports.__esModule = true;" and "require("lib");"

var vue = new Vue({ el: "#app", data: { text: "hello world" } }); 

PS:

I use DefinitelyTyped to get type definite

1 Answer 1

7

Change your tsconfig.json module to es2015 and moduleResolution to node.

{ "compilerOptions": { "target": "es5", "module": "es2015", "moduleResolution": "node" } } 

That is the recommended configuration.

The exports.__esModule and require('lib') are what happen when we transpile from an ES module to commonjs (with babel or with TypeScript).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.