Skip to content

Commit

Permalink
Merge pull request #46 from ensdomains/mdt/change-bundler
Browse files Browse the repository at this point in the history
change bundler for better tree shaking support
  • Loading branch information
mdtanrikulu authored Jan 8, 2024
2 parents 353eae0 + ee446ac commit f195214
Show file tree
Hide file tree
Showing 6 changed files with 456 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['12.x', '14.x', '16.x']
node: ['18.x', '20.x']
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.5",
"version": "0.3.6",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand All @@ -10,15 +10,14 @@
"src"
],
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build && ./patch.sh",
"start": "rollup -c --watch",
"build": "rollup -c",
"build:demo": "node ./example/build.js",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build && ./patch.sh",
"size": "size-limit"
},
"husky": {
Expand All @@ -39,7 +38,7 @@
"author": "Muhammed Tanrıkulu <[email protected]>",
"size-limit": [
{
"path": "dist/ens-avatar.cjs.production.min.js",
"path": "dist/index.js",
"limit": "200 KB",
"ignore": [
"jsdom"
Expand All @@ -54,14 +53,16 @@
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^7.0.5",
"@types/dompurify": "^2.3.3",
"@types/jsdom": "^16.2.14",
"@rollup/plugin-typescript": "^11.1.5",
"@size-limit/preset-small-lib": "^11.0.1",
"@types/dompurify": "^3.0.5",
"@types/jsdom": "^21.1.6",
"@types/url-join": "^4.0.1",
"dotenv": "^16.0.0",
"dotenv": "^16.3.1",
"esbuild": "^0.14.21",
"nock": "^13.2.2",
"size-limit": "^7.0.5",
"rollup": "^4.9.1",
"size-limit": "^11.0.1",
"tsdx": "^0.14.1",
"typescript": "^4.5.5"
},
Expand All @@ -78,6 +79,6 @@
"url-join": "^4.0.1"
},
"volta": {
"node": "16.14.0"
"node": "18.14.0"
}
}
34 changes: 0 additions & 34 deletions patch.sh

This file was deleted.

51 changes: 51 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import fs from 'fs';
import path from 'path';
import tsPlugin from '@rollup/plugin-typescript';

export default {
input: 'src/index.ts',
output: [
{
format: 'cjs',
file: './dist/index.js',
},
{
format: 'es',
dir: 'dist',
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames: chunk => {
return `${chunk.name === 'index' ? 'index.esm' : chunk.name}.js`;
},
},
],
plugins: [
tsPlugin({
declarationDir: './dist',
sourceMap: false,
}),
removeDist(),
],
};

function removeDist(options = {}) {
const { hook = 'buildStart', buildDir = 'dist' } = options;

return {
name: 'remove-dist',
[hook]: async () => {
const folderPath = path.join(process.cwd(), buildDir);
try {
fs.accessSync(folderPath, fs.F_OK);
fs.rmSync(folderPath, { recursive: true, force: true });
} catch (err) {
if (err.code !== 'ENOENT') throw err;
try {
fs.rmSync(folderPath, { recursive: true, force: true });
} catch (innerErr) {
console.log('An error occurred while removing the folder:', innerErr);
}
}
},
};
}
14 changes: 0 additions & 14 deletions tsdx.config.js

This file was deleted.

Loading

0 comments on commit f195214

Please sign in to comment.