Skip to content

Commit

Permalink
Switch to mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Mar 13, 2019
1 parent 5cddbdd commit 306358a
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/examples/01-simple-example/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>

<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../dist/esm/comlink.mjs";

async function init() {
const worker = new Worker("worker.js");
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/02-callback-example/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>

<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../dist/esm/comlink.mjs";

function callback(value) {
alert(`Result: ${value}`);
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/03-classes-example/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>

<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../dist/esm/comlink.mjs";

let instance1, instance2;
async function showState() {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/05-serviceworker-example/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>

<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../dist/esm/comlink.mjs";

async function initComlink() {
const { port1, port2 } = new MessageChannel();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/99-nonworker-examples/iframes/iframe.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>

<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../../dist/esm/comlink.mjs";
function add(a, b) {
return a + b;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/99-nonworker-examples/iframes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<iframe src="iframe.html"></iframe>
<script type="module">
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.js";
import * as Comlink from "../../../../dist/esm/comlink.js";
// import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
import * as Comlink from "../../../../dist/esm/comlink.mjs";
async function main() {
const ifr = document.querySelector("iframe");
await new Promise(resolve => (ifr.onload = resolve));
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function(config) {
included: false
},
{
pattern: "dist/**/*.js",
pattern: "dist/**/*.@(mjs|js)",
included: false
},
{
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "4.0.0-alpha.6",
"description": "Comlink makes WebWorkers enjoyable",
"main": "dist/umd/comlink.js",
"module": "dist/esm/comlink.js",
"module": "dist/esm/comlink.mjs",
"types": "dist/umd/comlink.d.ts",
"scripts": {
"build": "rollup -c",
Expand Down Expand Up @@ -43,6 +43,7 @@
"karma-safaritechpreview-launcher": "2.0.2",
"mocha": "5.2.0",
"prettier": "1.16.1",
"rimraf": "^2.6.3",
"rollup": "^1.6.0",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-typescript2": "^0.19.3",
Expand Down
6 changes: 5 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { terser } from "rollup-plugin-terser";

function config({ format, minify }) {
const dir = `dist/${format}/`;
const minifierSuffix = minify ? ".min" : "";
const ext = format === "esm" ? "mjs" : "js";
return {
input: "./src/comlink.ts",
output: {
name: "Comlink",
file: `${dir}/comlink${minify ? ".min" : ""}.js`,
file: `${dir}/comlink${minifierSuffix}.${ext}`,
format,
sourcemap: true
},
Expand Down Expand Up @@ -35,6 +37,8 @@ function config({ format, minify }) {
};
}

require("rimraf").sync("dist");

export default [
{ format: "esm", minify: false },
{ format: "esm", minify: true },
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/iframe.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="module">
import * as Comlink from "/base/dist/esm/comlink.js";
import * as Comlink from "/base/dist/esm/comlink.mjs";

Comlink.expose((a, b) => a + b, Comlink.windowEndpoint(self.parent));
</script>
2 changes: 1 addition & 1 deletion tests/iframe.comlink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/

import * as Comlink from "/base/dist/esm/comlink.js";
import * as Comlink from "/base/dist/esm/comlink.mjs";

describe("Comlink across iframes", function() {
beforeEach(function() {
Expand Down
2 changes: 1 addition & 1 deletion tests/same_window.comlink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/

import * as Comlink from "/base/dist/esm/comlink.js";
import * as Comlink from "/base/dist/esm/comlink.mjs";

class SampleClass {
constructor(counterInit = 1) {
Expand Down
2 changes: 1 addition & 1 deletion tests/worker.comlink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/

import * as Comlink from "/base/dist/esm/comlink.js";
import * as Comlink from "/base/dist/esm/comlink.mjs";

describe("Comlink across workers", function() {
beforeEach(function() {
Expand Down

0 comments on commit 306358a

Please sign in to comment.