-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cjs bundle output for @powersync/common.
- Loading branch information
Showing
6 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
node_modules | ||
lib | ||
dist | ||
tsconfig.tsbuildinfo | ||
cjs | ||
*.tsbuildinfo | ||
.vscode | ||
.DS_STORE | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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'; | ||
|
||
// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694 | ||
delete commandLineArgs.sourceMap; | ||
|
||
return { | ||
// esm input is better, even for cjs output | ||
input: 'lib/index.js', | ||
output: { | ||
file: 'dist/bundle.cjs', | ||
format: 'cjs', | ||
sourcemap: sourcemap | ||
}, | ||
plugins: [ | ||
json(), | ||
nodeResolve({ preferBuiltins: false, browser: true }), | ||
commonjs({}), | ||
inject({ | ||
Buffer: ['buffer', 'Buffer'], | ||
ReadableStream: ['web-streams-polyfill/ponyfill', 'ReadableStream'], | ||
// Used by can-ndjson-stream | ||
TextDecoder: ['text-encoding', 'TextDecoder'] | ||
}), | ||
terser() | ||
], | ||
// This makes life easier | ||
external: [ | ||
// This has dynamic logic - makes bundling hard | ||
'cross-fetch', | ||
// TODO: make the useDefaults logic better. Currently need access to this package directly | ||
'js-logger' | ||
] | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters