My tsconfig.json
file contains
{
"pilerOptions": {
"module": "esnext",
"target": "esnext",
}
}
But the piled JS files still use exports
/require
syntax.
How do I fix this?
EDIT:
My directory structure is as follows
- APIs/
- emails/
- sendEmail.ts
- oldFiles/
- file1.js
- file2.js
- index.js
- tsconfig.json
- package.json
I am running tsc
using the mand tsc APIs/emails/sendEmail.ts
from the root directory.
My tsconfig.json
file contains
{
"pilerOptions": {
"module": "esnext",
"target": "esnext",
}
}
But the piled JS files still use exports
/require
syntax.
How do I fix this?
EDIT:
My directory structure is as follows
- APIs/
- emails/
- sendEmail.ts
- oldFiles/
- file1.js
- file2.js
- index.js
- tsconfig.json
- package.json
I am running tsc
using the mand tsc APIs/emails/sendEmail.ts
from the root directory.
-
How are you calling
tsc
? – T.J. Crowder Commented Jul 21, 2022 at 7:10 -
from the root folder, i call
tsc a/b/c/file.ts
(thetsconfig.json
is in the root folder) – Will Zap Commented Jul 21, 2022 at 7:54 -
Your edit confirms my answer. By calling
tsc
that way, you're not using yourtsconfig.json
. (This is surprising, but true.). Just usetsc
with appropriateincludes
(see the answer), rather than giving a specific file. – T.J. Crowder Commented Jul 21, 2022 at 8:05
2 Answers
Reset to default 5Those settings are correct, so most likely you're not actually using that tsconfig.json
file. For instance, if you do tsc someFile.ts
, tsc
doesn't use the tsconfig.json
(surprisingly). Your best bet is probably to add an includes
to your configuration (so tsc
knows what it's piling) and then pile simply by invoking tsc
, which will look for a local tsconfig.json
.
{
"pilerOptions": {
"module": "esnext",
"target": "esnext"
},
"include": ["**/*.ts"]
}
Then in package.json
(for instance):
// ...
"scripts": {
"build": "tsc"
}
// ...
This config should work. But it's tsconfig.json
not tsconfig.js
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745099637a4611194.html
评论列表(0条)