Skip to content

Commit

Permalink
Babel Refactor (#1149)
Browse files Browse the repository at this point in the history
* upgrade babel, fix module build, remove babel runtime, target modern JS

* fix tests
  • Loading branch information
hipstersmoothie authored Feb 5, 2023
1 parent cebbdb7 commit f8c4bee
Show file tree
Hide file tree
Showing 39 changed files with 1,035 additions and 1,077 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults and supports es6-module, maintained node versions
24 changes: 9 additions & 15 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,30 @@ module.exports = (api) => {
api.cache(true);

return {
presets: ["@babel/preset-env"],
presets: [
[
"@babel/preset-env",
{
modules: process.env.BABEL_ENV === "module" ? false : "cjs",
useBuiltIns: false,
},
],
],

plugins: [
"@babel/proposal-class-properties",
"@babel/syntax-object-rest-spread",
process.env.BABEL_ENV !== "module" && "add-module-exports",
[
"transform-inline-environment-variables",
{ include: ["BABEL_ENV", "ENV"] },
],
[
"@babel/plugin-transform-runtime",
{
regenerator: true,
},
],
].filter(Boolean),

env: {
test: {
plugins: ["istanbul"],
},
development: {
plugins: [process.env.ENV !== "browser" && "source-map-support"].filter(
Boolean
),
},
module: {
presets: [["@babel/preset-env"]],
},
},
};
};
20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,16 @@
"@auto-it/first-time-contributor": "^10.38.4",
"@auto-it/magic-zero": "^10.38.4",
"@auto-it/protected-branch": "^10.38.4",
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-syntax-object-rest-spread": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.7.1",
"@babel/register": "^7.7.0",
"@babel/runtime": "^7.7.2",
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"all-contributors-cli": "^6.24.0",
"auto": "^10.38.4",
"babel-eslint": "^10.0.3",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-source-map-support": "^2.1.1",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-source-map-support": "^2.2.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"cross-env": "^6.0.0",
"dtslint": "^4.2.1",
Expand All @@ -69,7 +63,7 @@
"patch-package": "^6.5.1",
"prettier": "^2.8.3",
"should": "^13.2.3",
"source-map-support": "^0.5.13"
"source-map-support": "^0.5.21"
},
"husky": {
"hooks": {
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"author": "Oliver Moran <oliver.moran@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"any-base": "^1.1.0",
"buffer": "^5.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/core": "link:../core"
},
"publishConfig": {
Expand Down
12 changes: 0 additions & 12 deletions packages/jimp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,15 @@
"author": "Oliver Moran <oliver.moran@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/custom": "link:../custom",
"@jimp/plugins": "link:../plugins",
"@jimp/types": "link:../types",
"regenerator-runtime": "^0.13.3"
},
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-syntax-object-rest-spread": "^7.2.0",
"@babel/preset-env": "^7.7.1",
"@babel/register": "^7.7.0",
"@jimp/test-utils": "link:../test-utils",
"babel-eslint": "^10.0.3",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-source-map-support": "^2.1.1",
"express": "^4.17.1",
"path-browserify": "^1.0.1",
"source-map-support": "^0.5.13",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/jimp/test/scan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ describe("Scan (pixel matrix modification)", () => {
});

it("draw bars with iterate scan", async () => {
const image = await Jimp.create(8, 3);
const j = await Jimp.create(8, 3);

for (const { x, y, idx, image } of image.scanIterator(
for (const { x, y, idx, image } of j.scanIterator(
0,
0,
image.bitmap.width,
image.bitmap.height
j.bitmap.width,
j.bitmap.height
)) {
const color = [
[0xff, 0x00, 0x00],
Expand All @@ -52,7 +52,7 @@ describe("Scan (pixel matrix modification)", () => {
image.bitmap.data[idx + 3] = y === 2 ? 0x7f : 0xff;
}

image.getJGDSync().should.be.sameJGD(barsJGD, "Color bars");
j.getJGDSync().should.be.sameJGD(barsJGD, "Color bars");
});

it("draw bars with (get|set)PixelColor", async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/jimp/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
mode: isProd ? "production" : "development",
devtool: isProd ? "source-map" : "eval-cheap-module-source-map",
entry: "./src/index.js",
target: "web",
resolve: {
alias: {
pngjs: "pngjs/browser",
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-blit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-blur/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-circle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"tinycolor2": "^1.4.1"
},
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-contain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-cover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-crop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-displace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-dither/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-fisheye/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-flip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-gaussian/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-invert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-mask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-normalize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-print/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"load-bmfont": "^1.4.1"
},
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-resize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-rotate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-scale/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-shadow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-threshold/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/plugin-blit": "link:../plugin-blit",
"@jimp/plugin-blur": "link:../plugin-blur",
"@jimp/plugin-circle": "link:../plugin-circle",
Expand Down
1 change: 0 additions & 1 deletion packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"access": "public"
},
"dependencies": {
"@babel/runtime": "^7.7.2",
"pngjs": "^6.0.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/type-bmp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"bmp-js": "^0.1.0"
},
Expand Down
1 change: 0 additions & 1 deletion packages/type-gif/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"gifwrap": "^0.9.2",
"omggif": "^1.0.9"
Expand Down
1 change: 0 additions & 1 deletion packages/type-jpeg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"jpeg-js": "^0.4.4"
},
Expand Down
1 change: 0 additions & 1 deletion packages/type-png/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"pngjs": "^6.0.0"
},
Expand Down
1 change: 0 additions & 1 deletion packages/type-tiff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"utif2": "^4.0.1"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/bmp": "link:../type-bmp",
"@jimp/gif": "link:../type-gif",
"@jimp/jpeg": "link:../type-jpeg",
Expand Down
Loading

0 comments on commit f8c4bee

Please sign in to comment.