diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74c19c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/dist/ +/node_modules/ +/package-lock.json +/pnpm-lock.yaml +/shrinkwrap.yaml +/yarn.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d3bb3..87e9d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v2.2.0 + +- Expose proper ESM build (along with CJS build) using `pkg.exports` map + # v2.1.1 - Fix published types for `defiler.add(file)` diff --git a/package.json b/package.json index 1435aa4..8c12d4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "defiler", - "version": "2.1.1", + "version": "2.2.0", "description": "A small, strange building block", "keywords": [ "build", @@ -8,12 +8,19 @@ "async", "watch" ], - "type": "module", - "main": "src/index.js", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", "types": "types/index.d.ts", "files": [ "*.md", - "src", + "dist", "types" ], "engines": { @@ -28,5 +35,14 @@ "bugs": { "url": "https://github.com/Conduitry/defiler/issues" }, - "homepage": "https://conduitry.dev/defiler" + "homepage": "https://conduitry.dev/defiler", + "devDependencies": { + "@types/node": "=12", + "rollup": "^2" + }, + "scripts": { + "build": "rollup -c", + "dev": "rollup -cw", + "prepare": "npm run build" + } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..d9019e9 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,8 @@ +export default { + input: './src/index.js', + external: name => /^[a-z]/.test(name), + output: [ + { file: './dist/index.cjs', format: 'cjs', sourcemap: true, interop: false, preferConst: true }, + { file: './dist/index.mjs', format: 'esm', sourcemap: true, preferConst: true }, + ], +};