I have landed at this point after a long chain of changes to my build environment. I never used babel because it was not neccessary. But including the firebase package broke the build and all solutions I found online suggested using babel to transform the package to something that compiles. But when I am now compiling my code firebase can't be found at runtime.
My ts code:
import firebase from 'firebase/compat/app';
const auth = firebase.auth();
which generates this error at runtime:
Login.ts:15 Uncaught TypeError: app_1.default.auth is not a function
My gulp script looks like this:
let buildTask = browserify({
basedir: Config.srcPath,
debug: Flags.isDebug,
entries: ['./index.ts'],
cache: {},
packageCache: {}
})
.plugin('tsify')
.transform('babelify', {
presets: [
["@babel/preset-env", {
"useBuiltIns": "usage",
"corejs": 3,
}]
],
sourceMaps: true,
global: true,
extensions: ['.tsx', '.ts', '.js'],
ignore: [/\/node_modules\/(?!(firebase\/|@firebase\/))/]
})
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer());
And my tsconfig for completeness:
{
"compilerOptions": {
"strict": true,
"strictNullChecks": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"module": "CommonJS",
"target": "es6"
}
}
I am thankfull for any pointers!