Skip to content

Commit

Permalink
Resolve dexie#1127
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Sep 29, 2020
1 parent b2335f9 commit 7e710e4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"cd src",
"tsc [--watch 'Watching for file changes']",
"rollup -c ../tools/build-configs/rollup.config.js",
"rollup -c ../tools/build-configs/rollup.umd.config.js",
"node ../tools/replaceVersionAndDate.js ../dist/dexie.js",
"node ../tools/replaceVersionAndDate.js ../dist/dexie.mjs",
"dts-bundle-generator --umd-module-name Dexie -o ../dist/dexie.d.ts public/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/index-umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Issue #1127. Need another index.ts for the UMD module with only a default export
// like it was before.
// In practice though, the UMD export will also export the named export in
// https://github.com/dfahlander/Dexie.js/blob/c9187ae60c0d7a424f85bab3af179fbbc9901c8e/src/classes/dexie/dexie-static-props.ts#L223-L228
import Dexie from "./index";
export default Dexie;
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ DexiePromise.rejectionMapper = mapError;
// Let the async stack filter focus on app code and filter away frames from dexie.min.js:
Debug.setDebug(Debug.debug, dexieStackFrameFilter);

export { Dexie }; // Comply with public/index.d.ts.
export default Dexie;
13 changes: 1 addition & 12 deletions tools/build-configs/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,10 @@ const ERRORS_TO_IGNORE = [
export default {
input: path.resolve(__dirname, '../../tools/tmp/src/index.js'),
output: [{
file: path.resolve(__dirname, '../../dist/dexie.js'),
format: 'umd',
name: 'Dexie',
globals: {}, // For tests, use "QUnit". For addons, use "Dexie"
sourcemap: true,
banner: readFileSync(path.resolve(__dirname, 'banner.txt'))+""
.replace(/{version}/g, version)
.replace(/{date}/g, new Date().toDateString()),
},{
file: path.resolve(__dirname, '../../dist/dexie.mjs'),
format: 'es',
sourcemap: true,
banner: readFileSync(path.resolve(__dirname, 'banner.txt'))+""
.replace(/{version}/g, version)
.replace(/{date}/g, new Date().toDateString()),
banner: readFileSync(path.resolve(__dirname, 'banner.txt')),
}],
plugins: [
sourcemaps(),
Expand Down
38 changes: 38 additions & 0 deletions tools/build-configs/rollup.umd.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sourcemaps from 'rollup-plugin-sourcemaps';
import nodeResolve from 'rollup-plugin-node-resolve';
import cleanup from 'rollup-plugin-cleanup';

import {readFileSync} from 'fs';
import path from 'path';

const version = require(path.resolve(__dirname, '../../package.json')).version;

const ERRORS_TO_IGNORE = [
"CIRCULAR_DEPENDENCY" // Circular imports are OK. See https://github.com/rollup/rollup/issues/2271
];

export default {
input: path.resolve(__dirname, '../../tools/tmp/src/index-umd.js'),
output: [{
file: path.resolve(__dirname, '../../dist/dexie.js'),
format: 'umd',
name: 'Dexie',
globals: {}, // For tests, use "QUnit". For addons, use "Dexie"
sourcemap: true,
banner: readFileSync(path.resolve(__dirname, 'banner.txt')),
}],
plugins: [
sourcemaps(),
nodeResolve({module: true, jsnext: true, browser: true, ignoreGlobal: false}),
cleanup()
],
onwarn ({loc, frame, code, message}) {
if (ERRORS_TO_IGNORE.includes(code)) return;
if ( loc ) {
console.warn( `${loc.file} (${loc.line}:${loc.column}) ${message}` );
if ( frame ) console.warn( frame );
} else {
console.warn(`${code} ${message}`);
}
}
};

0 comments on commit 7e710e4

Please sign in to comment.