Skip to content

Commit cab7029

Browse files
committed
FIX transpile workers via babel to have the same config as the root project
1 parent 946c946 commit cab7029

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

babel.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ if (process.env['NODE_ENV'] === 'es5') {
7070
[
7171
'@babel/typescript',
7272
{
73+
loose: true,
7374
targets: {
7475
edge: '17',
7576
firefox: '60',

orga/performance-trackings.md

+5
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,12 @@ https://www.npmjs.com/package/babel-plugin-transform-async-to-promises
819819
820820
BEFORE:
821821

822+
core:
822823
Build-Size (minified+gzip):
823824
75489
824825

825826
AFTER:
827+
828+
core:
829+
Build-Size (minified+gzip):
830+
70723

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"@typescript-eslint/parser": "4.33.0",
169169
"assert": "2.0.0",
170170
"async-test-util": "1.7.3",
171+
"babel-loader": "8.2.3",
171172
"babel-plugin-transform-class-properties": "6.24.1",
172173
"brfs": "2.0.2",
173174
"browserify": "17.0.0",

src/plugins/worker/workers/tsconfig.json

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"moduleResolution": "node",
1010
"target": "es2017",
1111
"noEmit": false,
12+
13+
/**
14+
* @link https://spblog.net/post/2018/10/26/TypeScript-Tips-How-to-reduce-the-size-of-a-bundle
15+
*/
16+
"importHelpers": true,
17+
1218
"lib": [
1319
"es2017",
1420
"webworker"

src/plugins/worker/workers/webpack.config.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const projectRootPath = path.resolve(
66
'../../../../'
77
);
88

9+
const babelConfig = require('../../../../babel.config');
910
module.exports = {
1011
entry: {
1112
'lokijs-incremental-indexeddb': './src/plugins/worker/workers/lokijs-incremental-indexeddb.worker.ts',
@@ -17,6 +18,7 @@ module.exports = {
1718
},
1819
output: {
1920
filename: '[name].worker.js',
21+
clean: true,
2022
path: path.resolve(
2123
projectRootPath,
2224
'dist/workers'
@@ -34,15 +36,19 @@ module.exports = {
3436
devtool: 'source-map',
3537
module: {
3638
rules: [
39+
/**
40+
* We transpile the typscript via babel instead of ts-loader.
41+
* This ensures we have the exact same babel config
42+
* as the root RxDB project.
43+
*/
3744
{
3845
test: /\.tsx?$/,
46+
exclude: /(node_modules)/,
3947
use: {
40-
loader: 'ts-loader',
41-
options: {
42-
transpileOnly: true
43-
}
48+
loader: 'babel-loader',
49+
options: babelConfig
4450
}
45-
},
51+
}
4652
],
4753
},
4854
resolve: {

tsconfig.json

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"noEmit": true,
2020
"declaration": true,
2121

22+
/**
23+
* @link https://spblog.net/post/2018/10/26/TypeScript-Tips-How-to-reduce-the-size-of-a-bundle
24+
*/
25+
"importHelpers": true,
26+
2227
"typeRoots": [
2328
"./src/types/modules"
2429
]

0 commit comments

Comments
 (0)