Skip to content

Commit

Permalink
Minified bundles for common and react-native.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriztiaan committed Jul 23, 2024
1 parent 047c141 commit 5e03971
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 297 deletions.
5 changes: 3 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup -c rollup.config.mjs",
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"clean": "rm -rf lib tsconfig.tsbuildinfo dist",
"test": "vitest"
},
"dependencies": {
Expand All @@ -35,6 +35,7 @@
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/lodash": "^4.14.197",
"@types/node": "^20.5.9",
"@types/uuid": "^9.0.1",
Expand All @@ -48,7 +49,7 @@
"rollup": "4.14.3",
"rsocket-core": "1.0.0-alpha.3",
"rsocket-websocket-client": "1.0.0-alpha.3",
"text-encoding": "^0.7.0",
"text-encoding": "^0.7.0",
"typescript": "^5.5.3",
"vitest": "^1.5.2",
"web-streams-polyfill": "3.2.1"
Expand Down
4 changes: 3 additions & 1 deletion packages/common/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import commonjs from '@rollup/plugin-commonjs';
import inject from '@rollup/plugin-inject';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';

export default (commandLineArgs) => {
const sourcemap = (commandLineArgs.sourceMap || 'true') == 'true';
Expand All @@ -25,7 +26,8 @@ export default (commandLineArgs) => {
ReadableStream: ['web-streams-polyfill/ponyfill', 'ReadableStream'],
// Used by can-ndjson-stream
TextDecoder: ['text-encoding', 'TextDecoder']
})
}),
terser()
],
// This makes life easier
external: [
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"scripts": {
"build": "tsc -b && rollup -c rollup.config.mjs",
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"clean": "rm -rf lib tsconfig.tsbuildinfo dist",
"watch": "tsc -b -w"
},
"repository": {
Expand Down Expand Up @@ -46,6 +46,7 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@types/async-lock": "^1.4.0",
"async-lock": "^1.4.0",
"bson": "^6.6.0",
Expand Down
15 changes: 10 additions & 5 deletions packages/react-native/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import path from 'path';
import { fileURLToPath } from 'url';
import terser from '@rollup/plugin-terser';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -25,7 +26,11 @@ export default (commandLineArgs) => {
},
plugins: [
// We do this so that we can inject on BSON's crypto usage.
replace({'const { crypto } = globalThis;': '// removed crypto destructuring assingment from globalThis', delimiters: ['', ''], preventAssignment: true}),
replace({
'const { crypto } = globalThis;': '// removed crypto destructuring assingment from globalThis',
delimiters: ['', ''],
preventAssignment: true
}),
json(),
nodeResolve({ preferBuiltins: false }),
commonjs({}),
Expand All @@ -35,12 +40,12 @@ export default (commandLineArgs) => {
TextEncoder: ['text-encoding', 'TextEncoder'],
TextDecoder: ['text-encoding', 'TextDecoder'],
// injecting our crypto implementation
'crypto': path.resolve( './vendor/crypto.js' ),

crypto: path.resolve('./vendor/crypto.js')
}),
alias({
entries: [{ find: 'bson', replacement: path.resolve(__dirname, '../../node_modules/bson/lib/bson.rn.cjs')}]
})
entries: [{ find: 'bson', replacement: path.resolve(__dirname, '../../node_modules/bson/lib/bson.rn.cjs') }]
}),
terser()
],
external: [
'@journeyapps/react-native-quick-sqlite',
Expand Down
Loading

0 comments on commit 5e03971

Please sign in to comment.