Skip to content

Commit

Permalink
switch from browserify to webpack (#1140)
Browse files Browse the repository at this point in the history
* switch from browserify to webpack

* upgrade dtslint

* add browser field

* fix build cache

* remove support for really old TS versions
  • Loading branch information
hipstersmoothie committed Feb 4, 2023
1 parent 3ca7608 commit ecdd71e
Show file tree
Hide file tree
Showing 25 changed files with 1,112 additions and 2,382 deletions.
2 changes: 2 additions & 0 deletions .github/actions/build-cache/action.yml
Expand Up @@ -10,5 +10,7 @@ runs:
path: |
node_modules
packages/*/dist
packages/*/es
packages/jimp/browser/lib
key: ${{ github.run_id }}
restore-keys: ${{ github.run_id }}
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -48,3 +48,4 @@ package-lock.json
dist/
# ESM Version
es/
jimp.js.*
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -31,7 +31,7 @@ If you know how to code, we welcome you to send fixes and new features, but in o
```sh
yarn # install and link all packages in monorepo

yarn build # build ES5, ESM, and browserify
yarn build
# or
yarn build:watch # build ES5 version in watch mode. Good to run while testing or developing.
```
Expand Down
6 changes: 2 additions & 4 deletions package.json
Expand Up @@ -44,7 +44,7 @@
"babel-plugin-source-map-support": "^2.1.1",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"cross-env": "^6.0.0",
"dtslint": "^0.9.8",
"dtslint": "^4.2.1",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-xo": "^0.43.1",
Expand All @@ -58,15 +58,13 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"lerna": "^3.16.4",
"lerna-changelog": "^0.8.2",
"lint-staged": "^9.2.5",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"patch-package": "^6.5.1",
"prettier": "^2.8.3",
"should": "^13.2.3",
"source-map-support": "^0.5.13",
"watchify": "^3.11.1"
"source-map-support": "^0.5.13"
},
"auto": {
"plugins": [
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Expand Up @@ -5,6 +5,7 @@
"main": "dist/index.js",
"module": "es/index.js",
"types": "types/index.d.ts",
"sideEffects": false,
"files": [
"dist",
"es",
Expand Down
2 changes: 1 addition & 1 deletion packages/custom/types/index.d.ts
@@ -1,4 +1,4 @@
// TypeScript Version: 3.1
// Minimum TypeScript Version: 3.2
// See the `jimp` package index.d.ts for why the version is not 2.8
import {
FunctionRet,
Expand Down
15 changes: 0 additions & 15 deletions packages/jimp/README.md
Expand Up @@ -77,21 +77,6 @@ If you're using a web bundles (webpack, rollup, parcel) you can benefit from usi
import Jimp from "jimp/es";
```

### WebPack

If you're using webpack you can set `process.browser` to true and your build of jimp will exclude certain parts, making it load faster.

```js
{
plugins: [
new webpack.DefinePlugin({
'process.browser': 'true'
}),
...
],
}
```

## Basic usage

The static `Jimp.read` method takes the path to a file, URL, dimensions, a Jimp instance or a buffer and returns a Promise:
Expand Down
2 changes: 1 addition & 1 deletion packages/jimp/browser/examples/example1.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>
<h1>Demonstrates loading a local file using Jimp on the main thread</h1>
<script src="../lib/jimp.min.js"></script>
<script src="../lib/jimp.js"></script>
<script>
Jimp.read(
"https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg"
Expand Down
2 changes: 1 addition & 1 deletion packages/jimp/browser/examples/jimp-worker.js
@@ -1,7 +1,7 @@
/* eslint-env worker */
/* global Jimp */

importScripts("../lib/jimp.min.js");
importScripts("../lib/jimp.js");

self.addEventListener("message", (e) => {
Jimp.read(e.data).then((lenna) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jimp/browser/examples/test.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>
<!-- Demonstrates loading a local file using Jimp on the main thread -->
<script src="../lib/jimp.min.js"></script>
<script src="../lib/jimp.js"></script>
<script>
function dropShadow(x, y, b, a) {
var img = new Jimp(
Expand Down
1 change: 0 additions & 1 deletion packages/jimp/browser/lib/fonts

This file was deleted.

35 changes: 6 additions & 29 deletions packages/jimp/package.json
Expand Up @@ -5,13 +5,7 @@
"main": "dist/index.js",
"module": "es/index.js",
"types": "types/index.d.ts",
"typesVersions": {
">=3.1.0-0": {
"*": [
"types/ts3.1/index.d.ts"
]
}
},
"browser": "browser/lib/jimp.js",
"tonicExampleFilename": "example.js",
"files": [
"browser",
Expand All @@ -26,16 +20,15 @@
"test": "cross-env BABEL_ENV=test mocha --require @babel/register",
"test:watch": "npm run test -- --reporter min --watch",
"test:coverage": "nyc npm run test",
"browser-build": "node tools/browser-build.js test",
"build": "npm run build:browser && npm run build:node:production && npm run build:module",
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
"build:debug": "npm run build:browser:debug && npm run build:node:debug",
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
"build:node:production": "cross-env BABEL_ENV=production npm run build:node",
"build:browser": "cross-env BABEL_ENV=production node tools/browser-build.js prepublish",
"build:browser:debug": "cross-env BABEL_ENV=development ENV=browser node tools/browser-build.js prepublish"
"build:browser": "cross-env NODE_ENV=production webpack",
"build:browser:debug": "cross-env NODE_ENV=development ENV=browser webpack"
},
"keywords": [
"image",
Expand Down Expand Up @@ -70,27 +63,11 @@
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-source-map-support": "^2.1.1",
"babelify": "^10.0.0",
"browserify": "^16.5.0",
"cross-env": "^6.0.0",
"dtslint": "^0.9.8",
"envify": "^4.1.0",
"eslint": "^6.4.0",
"express": "^4.17.1",
"husky": "^3.0.5",
"karma": "^4.3.0",
"karma-browserify": "^6.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^1.2.0",
"lerna": "^3.16.4",
"lerna-changelog": "^0.8.2",
"lint-staged": "^9.2.5",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"path-browserify": "^1.0.1",
"source-map-support": "^0.5.13",
"tfilter": "^1.0.1",
"uglify-js": "^3.6.0",
"watchify": "^3.11.1"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
},
"nyc": {
"sourceMap": false,
Expand Down
175 changes: 0 additions & 175 deletions packages/jimp/tools/browser-build.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/jimp/tools/server.js
Expand Up @@ -6,6 +6,7 @@ const express = require("express");
const app = express();

app.use(express.static(path.resolve(__dirname, "../browser")));
app.use(express.static(path.resolve(__dirname, "../")));
app.listen(8080);

console.log("Serving on http://127.0.0.1:8080");

0 comments on commit ecdd71e

Please sign in to comment.