I would like to make code transpiled by TypeScript to JavaScript be able to run in the browser:
ka@Karl-Laptop MINGW64 ~/Development/async (km/client-library)
$ npx browserify ./dist/index.js -t babelify -o ./dist/bundle.js
C:\Users\karl\Development\async\dist\index.js:1
export * from './shared';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
I read the following: https://babeljs.io/setup#installation via clicking on the browserify button. But it didn't help at all (I installed npm install --save-dev babelify babel-core --save-exact and ran npx browserify ./dist/index.js -t babelify -o ./dist/bundle.js, same error).
./dist/index.js file:
export * from './shared';
export * from './client';
export * from './server';
//# sourceMappingURL=index.js.map
tsconfig.js file:
{
"compilerOptions": {
"target": "ES5",
"module": "ES2015",
"declaration": true,
"lib": ["ES2016", "ES2017", "ES2018", "ES2019", "ES2018", "ES2019", "ES2020", "dom"],
"moduleResolution": "node",
"sourceMap": true,
"outDir": "./dist/",
"removeComments": true,
"esModuleInterop": true,
"baseUrl": ".",
"resolveJsonModule": true,
"strict": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"types": ["node", "jest"]
},
"exclude": ["./dist/", "./coverage/", "./report/"],
"include": ["./src/**/*"]
}
So from TypeScript -> Javascript -> ES5. As per usual I'm guessing Babel is needed to be configured but I am lost as to what exactly it needs.