PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 24, 2022

[FIXED] How to convert typescript modules to javascript

 August 24, 2022     javascript, module, tsconfig, typescript     No comments   

Issue

I have a src working directory like this:

- src
  - functions
  - final
  - utils

I have two files, both inside "final" which I need to transpile from typescript to javascript to run in browser.

The thing is: my final files are importing functions and classes from the other src folders files, but when I transpile it into javascript, it does not work since the imported lines does not actually brings in the functions and classes

my tsconfig.json looks like this:

{
  "compilerOptions": {
"target": "es3",
"lib": ["es6", "dom", "es2017", "ES2021"],
"module": "commonjs",
"rootDir": "./src", 
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}

What can I do in order to have it transpiled with the modules to the javascript files I need??


Solution

tsc only compiles files in place. It does not bundle.

To run your project in the browser, you typically need a bundler (such as webpack, parcel, vite, or rollup) to compile and package your code for use in web browsers.



Answered By - Alex Wayne
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing