Skip to content

Commit

Permalink
changed dist
Browse files Browse the repository at this point in the history
  • Loading branch information
VicenteVicente committed Sep 1, 2024
1 parent 7049e97 commit 8885ec7
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 46 deletions.
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@ import initREmatch from 'rematch-javascript';

Make the `initREmatch` function available globally with:

The IIFE versions

```html
<!-- Direct reference non-minified -->
<script src="./lib/browser/rematch-javascript"></script>
<script src="./lib/browser/rematch.iife.js"></script>
<!-- Direct reference minified -->
<script src="./lib/browser/rematch.min.js"></script>
<script src="./lib/browser/rematch.iife.min.js"></script>

<!-- unpkg CDN non-minified -->
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.js"></script>
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.iife.js"></script>
<!-- unpkg CDN minified -->
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.min.js"></script>
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.iife.min.js"></script>

<!-- jsDelivr CDN non-minified -->
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.iife.js"></script>
<!-- jsDelivr CDN minified -->
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.min.iife.js"></script>
```

Or use the ESM versions
The ESM versions

```html
<script type="module">
Expand All @@ -61,6 +63,25 @@ Or use the ESM versions
</script>
```

The UMD versions

```html
<!-- Direct reference non-minified -->
<script src="./lib/browser/rematch.umd.js"></script>
<!-- Direct reference minified -->
<script src="./lib/browser/rematch.umd.min.js"></script>

<!-- unpkg CDN non-minified -->
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.umd.js"></script>
<!-- unpkg CDN minified -->
<script src="https://unpkg.com/rematch-javascript@latest/lib/browser/rematch.umd.min.js"></script>

<!-- jsDelivr CDN non-minified -->
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.umd.js"></script>
<!-- jsDelivr CDN minified -->
<script src="https://cdn.jsdelivr.net/npm/rematch-javascript@latest/lib/browser/rematch.umd.min.js"></script>
```

## Usage

As said before, `REmatch-javascript` was built with emscripten, so it uses [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly) to run. The `.wasm` code is embedded directly into the library's code, so it is not needed to bundle or import it.
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<title>Document</title>
</head>
<body></body>
<!-- <script type="module">
import initREmatch from "./lib/browser/rematch.esm.min.js";
<script type="module">
import initREmatch from "./lib/rematch.esm.min.js";
(async () => {
const REmatch = await initREmatch();

Expand All @@ -26,8 +26,8 @@
matchIterator.free();
console.log(spans);
})();
</script> -->
<script src="lib/browser/rematch.min.js"></script>
</script>
<!-- <script src="lib/browser/rematch.umd.min.js"></script>
<script>
(async () => {
const REmatch = await initREmatch();
Expand All @@ -47,5 +47,5 @@
matchIterator.free();
console.log(spans);
})();
</script>
</script> -->
</html>
47 changes: 42 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@
"url": "https://github.com/REmatchChile/REmatch-javascript/issues"
},
"homepage": "https://github.com/REmatchChile/REmatch-javascript#readme",
"version": "1.0.0",
"version": "1.1.0",
"description": "JavaScript bindings for REmatch, an information extraction focused regex library that uses constant delay algoirthms.",
"author": "Vicente Calisto",
"license": "MIT",
"main": "lib/index.js",
"browser": "lib/index.js",
"files": [
"lib/",
"LICENSE",
"README.md",
"package.json"
],
"scripts": {
"build": "npm run clean:build && babel src --out-dir lib",
"rollup": "rollup -c --bundleConfigAsCjs",
"build:old": "npm run clean:build && babel src --out-dir lib",
"build": "npm run clean:build && rollup -c --bundleConfigAsCjs",
"test": "jest --verbose",
"prepublishOnly": "npm run build && npm run test && npm run rollup",
"prepublishOnly": "npm run build && npm run test",
"clean:build": "rimraf lib/"
},
"keywords": [
Expand All @@ -51,6 +50,7 @@
"jest-environment-jsdom": "^29.7.0",
"rimraf": "^6.0.1",
"rollup": "^4.21.1",
"rollup-plugin-node-builtins": "^2.1.2"
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-polyfill-node": "^0.13.0"
}
}
}
45 changes: 39 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import builtins from "rollup-plugin-node-builtins";
const SRC_DIR = "src";
const INPUT = SRC_DIR + "/index.js";
const LIB_DIR = "lib";
const OUTPUT_PREFIX = LIB_DIR + "/browser/rematch";
const OUTPUT_PREFIX = LIB_DIR + "/rematch";
const MINIFIER = terser({ keep_classnames: true, keep_fnames: true });
const PLUGINS = [nodeResolve({ preferBuiltins: false, browser: true }), , commonjs(), builtins()];
const PLUGINS = [
nodeResolve({ main: false, module: true, browser: true, preferBuiltins: false }),
builtins(),
commonjs(),
];

const COMMON_CONFIG = {
input: INPUT,
Expand All @@ -18,7 +22,7 @@ const COMMON_CONFIG = {
const IIFE_CONFIG = {
...COMMON_CONFIG,
output: {
file: OUTPUT_PREFIX + ".js",
file: OUTPUT_PREFIX + ".iife.js",
format: "iife",
sourcemap: false,
name: "initREmatch",
Expand All @@ -31,15 +35,25 @@ const ESM_CONFIG = {
file: OUTPUT_PREFIX + ".esm.js",
format: "es",
sourcemap: false,
name: "REmatch",
name: "initREmatch",
},
};

const UMD_CONFIG = {
...COMMON_CONFIG,
output: {
file: OUTPUT_PREFIX + ".umd.js",
format: "umd",
sourcemap: false,
name: "initREmatch",
},
};

const IIFE_MIN_CONFIG = {
...IIFE_CONFIG,
output: {
...IIFE_CONFIG.output,
file: OUTPUT_PREFIX + ".min.js",
file: OUTPUT_PREFIX + ".iife.min.js",
},
plugins: [...IIFE_CONFIG.plugins, MINIFIER],
};
Expand All @@ -53,4 +67,23 @@ const ESM_MIN_CONFIG = {
plugins: [...ESM_CONFIG.plugins, MINIFIER],
};

export default [IIFE_CONFIG, ESM_CONFIG, IIFE_MIN_CONFIG, ESM_MIN_CONFIG];
const UMD_MIN_CONFIG = {
...UMD_CONFIG,
output: {
...UMD_CONFIG.output,
file: OUTPUT_PREFIX + ".umd.min.js",
},
plugins: [...UMD_CONFIG.plugins, MINIFIER],
};

const INDEX_CONFIG = {
...COMMON_CONFIG,
output: {
file: LIB_DIR + "/index.js",
format: "cjs",
name: "initREmatch",
},
plugins: [...COMMON_CONFIG.plugins],
};

export default [IIFE_CONFIG, ESM_CONFIG, UMD_CONFIG, IIFE_MIN_CONFIG, ESM_MIN_CONFIG, UMD_MIN_CONFIG, INDEX_CONFIG];
15 changes: 14 additions & 1 deletion src/index.js

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions src/rematch-bindings.js

This file was deleted.

0 comments on commit 8885ec7

Please sign in to comment.