diff --git a/README.md b/README.md index 9b9385f..b7d6aaf 100644 --- a/README.md +++ b/README.md @@ -548,6 +548,10 @@ purchase({ id: 'sword', name: 'Massive shiny sword', price: 2 }) ``` +## ESM and CJS bundles + +The TypeScript sources are transpiled to both CommonJS and ESM module systems, but the CommonJS bundle is still used for both `require` and `import` statements. This prevents a possible "Dual package hazard". See https://github.com/appy-one/acebase/discussions/98 for more info. + ## More information See *acebase-server* for more information about running an AceBase server ([npm](https://www.npmjs.com/package/acebase-server), [github](https://github.com/appy-one/acebase-server)) diff --git a/create-package-files b/create-package-files new file mode 100644 index 0000000..902e2c1 --- /dev/null +++ b/create-package-files @@ -0,0 +1,37 @@ +#!/bin/bash + +# Create CommonJS package.json +cat >dist/cjs/package.json <dist/cjs/index.d.ts <dist/esm/package.json <dist/esm/index.d.ts < (http://appy.one)", "license": "MIT", "dependencies": { - "acebase-core": "^1.22.4", + "acebase-core": "file:../acebase-core", "socket.io-client": "^2.5.0" }, "devDependencies": { @@ -69,6 +87,7 @@ "browserify": "^17.0.0", "eslint": "^8.25.0", "terser": "^5.15.1", + "tsc-esm-fix": "^2.20.5", "typescript": "^4.8.4" } }