From b78cdbe22edb078fa751027e100fc7dec60d86af Mon Sep 17 00:00:00 2001 From: Kristofer Baxter Date: Thu, 25 Jun 2020 10:39:39 -0700 Subject: [PATCH 1/4] v0.25.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf4f86e47..d2c6e258f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ampproject/worker-dom", - "version": "0.25.0", + "version": "0.25.1", "description": "A facsimile of a modern DOM implementation intended to run in a Web Worker.", "main": "dist/main", "files": [ From 990ebf303556fa12a3c1a5b949f7df4f1f50c13c Mon Sep 17 00:00:00 2001 From: Kristofer Baxter Date: Tue, 8 Sep 2020 08:56:45 -0700 Subject: [PATCH 2/4] Update to latest versions --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index c8a838c17..84bd6fb84 100644 --- a/package.json +++ b/package.json @@ -39,34 +39,34 @@ "devDependencies": { "@ampproject/filesize": "4.2.0", "@ampproject/rollup-plugin-closure-compiler": "0.26.0", - "@babel/cli": "7.10.1", - "@babel/core": "7.10.2", - "@babel/plugin-proposal-class-properties": "7.10.1", - "@babel/plugin-proposal-object-rest-spread": "7.10.1", - "@babel/preset-env": "7.10.2", + "@babel/cli": "7.11.6", + "@babel/core": "7.11.6", + "@babel/plugin-proposal-class-properties": "7.10.4", + "@babel/plugin-proposal-object-rest-spread": "7.11.0", + "@babel/preset-env": "7.11.5", "@rollup/plugin-replace": "2.3.3", - "@types/node": "14.6.3", + "@types/node": "14.6.4", "@types/sinon": "9.0.5", "acorn": "8.0.1", "acorn-walk": "8.0.0", - "ava": "3.8.2", + "ava": "3.12.1", "babel-plugin-minify-replace": "0.5.0", "babel-plugin-transform-remove-console": "6.9.4", "cross-env": "7.0.2", "esm": "3.2.25", - "husky": "4.2.5", + "husky": "4.3.0", "jsdom": "16.4.0", - "lint-staged": "10.2.9", + "lint-staged": "10.3.0", "magic-string": "0.25.7", "np": "6.5.0", "npm-run-all": "4.1.5", "polka": "0.5.2", "prettier": "2.1.1", "rimraf": "3.0.2", - "rollup": "2.26.9", + "rollup": "2.26.11", "rollup-plugin-analyzer": "3.3.0", "rollup-plugin-babel": "4.4.0", - "rollup-plugin-terser": "7.0.1", + "rollup-plugin-terser": "7.0.2", "sinon": "9.0.3", "sirv": "1.0.6", "tslint": "6.1.3", @@ -113,7 +113,7 @@ ] }, "volta": { - "node": "14.9.0", + "node": "14.10.0", "yarn": "1.22.5" }, "publishConfig": { From aa017c6299526e9350bc94467b809af993b45187 Mon Sep 17 00:00:00 2001 From: Kristofer Baxter Date: Tue, 8 Sep 2020 14:45:54 -0700 Subject: [PATCH 3/4] Remove ES5 transpilation --- config/rollup.main-thread.js | 58 +---------- config/rollup.plugins.js | 37 +------ config/rollup.worker-thread.js | 135 +------------------------ demo/call-function/index.html | 12 ++- demo/canvas/index.html | 16 --- demo/clone-node/index.html | 20 ---- demo/comments/index.html | 16 --- demo/default-input-listener/index.html | 17 ---- demo/empty/index.html | 16 --- demo/hello-world/index.html | 16 --- demo/preact-dbmon/index.html | 20 +--- demo/preact-map/index.html | 16 --- demo/preact-todomvc/index.html | 16 --- demo/prime-numbers/index.html | 16 --- demo/react-map/index.html | 16 --- demo/svg/index.html | 16 --- demo/two-roots/index.html | 18 ---- demo/vanilla-script/index.html | 16 --- demo/vue-todomvc/index.html | 6 -- demo/webassembly/index.html | 16 --- package.json | 32 ++---- 21 files changed, 25 insertions(+), 506 deletions(-) diff --git a/config/rollup.main-thread.js b/config/rollup.main-thread.js index ae2dfdcf1..2b3199818 100644 --- a/config/rollup.main-thread.js +++ b/config/rollup.main-thread.js @@ -14,8 +14,6 @@ * limitations under the License. */ -import compiler from '@ampproject/rollup-plugin-closure-compiler'; -import { terser } from 'rollup-plugin-terser'; import replace from '@rollup/plugin-replace'; import { babelPlugin, removeDebugCommandExecutors, removeWorkerWhitespace } from './rollup.plugins.js'; @@ -34,11 +32,8 @@ const ESModules = [ WORKER_DOM_DEBUG: false, }), babelPlugin({ - transpileToES5: false, allowConsole: false, }), - compiler(), - terser(), ], }, { @@ -54,7 +49,6 @@ const ESModules = [ WORKER_DOM_DEBUG: true, }), babelPlugin({ - transpileToES5: false, allowConsole: true, }), ], @@ -73,11 +67,8 @@ const ESModules = [ WORKER_DOM_DEBUG: false, }), babelPlugin({ - transpileToES5: false, allowConsole: false, }), - compiler(), - terser(), ], }, { @@ -93,57 +84,10 @@ const ESModules = [ WORKER_DOM_DEBUG: true, }), babelPlugin({ - transpileToES5: false, allowConsole: true, }), ], }, ]; -const IIFEModules = [ - { - input: 'output/main-thread/index.js', - output: { - file: 'dist/main.js', - format: 'iife', - name: 'MainThread', - sourcemap: true, - }, - plugins: [ - removeWorkerWhitespace(), - removeDebugCommandExecutors(), - replace({ - WORKER_DOM_DEBUG: false, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: false, - }), - compiler(), - terser(), - ], - }, - { - input: 'output/main-thread/index.js', - output: { - file: 'dist/debug/main.js', - format: 'iife', - name: 'MainThread', - sourcemap: true, - }, - plugins: [ - removeWorkerWhitespace(), - replace({ - WORKER_DOM_DEBUG: true, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: true, - }), - compiler(), - terser(), - ], - }, -]; - -export default [...ESModules, ...IIFEModules]; +export default [...ESModules]; diff --git a/config/rollup.plugins.js b/config/rollup.plugins.js index 45a698cfe..cc4818801 100644 --- a/config/rollup.plugins.js +++ b/config/rollup.plugins.js @@ -14,7 +14,7 @@ * limitations under the License. */ -import babel from 'rollup-plugin-babel'; +import babel from '@rollup/plugin-babel'; import MagicString from 'magic-string'; import fs from 'fs'; import * as path from 'path'; @@ -27,42 +27,13 @@ const walk = require('acorn-walk'); * - allowConsole Should we allow `console` methods in the output? * - allowPostMessage Should we allow postMessage to/from the Worker? */ -export function babelPlugin({ transpileToES5, allowConsole = false, allowPostMessage = true }) { - const targets = transpileToES5 ? { browsers: ['last 2 versions', 'ie >= 11', 'safari >= 7'] } : { esmodules: true }; +export function babelPlugin({ allowConsole = false }) { const exclude = allowConsole ? ['error', 'warn', 'trace', 'info', 'log', 'time', 'timeEnd'] : []; return babel({ exclude: 'node_modules/**', - presets: [ - [ - '@babel/env', - { - targets, - loose: !transpileToES5, - modules: false, - bugfixes: true, - }, - ], - ], - plugins: [ - ['@babel/plugin-proposal-object-rest-spread'], - ['@babel/proposal-class-properties'], - [ - 'babel-plugin-minify-replace', - { - replacements: [ - { - identifierName: '__ALLOW_POST_MESSAGE__', - replacement: { - type: 'booleanLiteral', - value: allowPostMessage, - }, - }, - ], - }, - ], - ['babel-plugin-transform-remove-console', { exclude }], - ], + babelHelpers: 'bundled', + plugins: [['babel-plugin-transform-remove-console', { exclude }]], }); } diff --git a/config/rollup.worker-thread.js b/config/rollup.worker-thread.js index 4191d5325..c407671eb 100644 --- a/config/rollup.worker-thread.js +++ b/config/rollup.worker-thread.js @@ -14,19 +14,9 @@ * limitations under the License. */ -import compiler from '@ampproject/rollup-plugin-closure-compiler'; -import { terser } from 'rollup-plugin-terser'; import replace from '@rollup/plugin-replace'; import { babelPlugin } from './rollup.plugins.js'; -// Compile plugins should always be added at the end of the plugin list. -const compilePlugins = [ - compiler({ - env: 'CUSTOM', - }), - terser(), -]; - // Workers do not natively support ES Modules containing `import` or `export` statments. // So, here we continue to use the '.mjs' extension to indicate newer ECMASCRIPT support // but ensure the code can be run within a worker by putting it inside a named iife. @@ -44,10 +34,8 @@ const ESModules = [ WORKER_DOM_DEBUG: false, }), babelPlugin({ - transpileToES5: false, allowConsole: false, }), - ...compilePlugins, ], }, { @@ -63,7 +51,6 @@ const ESModules = [ WORKER_DOM_DEBUG: true, }), babelPlugin({ - transpileToES5: false, allowConsole: true, }), ], @@ -81,10 +68,8 @@ const ESModules = [ WORKER_DOM_DEBUG: false, }), babelPlugin({ - transpileToES5: false, allowConsole: false, }), - ...compilePlugins, ], }, { @@ -97,44 +82,6 @@ const ESModules = [ }, plugins: [ babelPlugin({ - transpileToES5: false, - allowConsole: true, - }), - ], - }, - { - input: 'output/worker-thread/index.amp.js', - output: { - file: 'dist/amp-production/worker/worker.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: false, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: false, - }), - ...compilePlugins, - ], - }, - { - input: 'output/worker-thread/index.amp.js', - output: { - file: 'dist/amp-debug/worker/worker.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: true, - }), - babelPlugin({ - transpileToES5: true, allowConsole: true, }), ], @@ -152,10 +99,8 @@ const ESModules = [ WORKER_DOM_DEBUG: false, }), babelPlugin({ - transpileToES5: false, allowConsole: true, }), - ...compilePlugins, ], }, { @@ -171,88 +116,10 @@ const ESModules = [ WORKER_DOM_DEBUG: true, }), babelPlugin({ - transpileToES5: false, - allowConsole: true, - }), - ], - }, - { - input: 'output/worker-thread/index.nodom.amp.js', - output: { - file: 'dist/amp-production/worker/worker.nodom.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: false, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: false, - }), - ...compilePlugins, - ], - }, - { - input: 'output/worker-thread/index.nodom.amp.js', - output: { - file: 'dist/amp-debug/worker/worker.nodom.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: true, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: true, - }), - ], - }, -]; - -const IIFEModules = [ - { - input: 'output/worker-thread/index.js', - output: { - file: 'dist/worker/worker.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: false, - }), - babelPlugin({ - transpileToES5: true, - allowConsole: false, - }), - ...compilePlugins, - ], - }, - { - input: 'output/worker-thread/index.js', - output: { - file: 'dist/debug/worker/worker.js', - format: 'iife', - name: 'WorkerThread', - sourcemap: true, - }, - plugins: [ - replace({ - WORKER_DOM_DEBUG: true, - }), - babelPlugin({ - transpileToES5: true, allowConsole: true, }), ], }, ]; -export default [...ESModules, ...IIFEModules]; +export default [...ESModules]; diff --git a/demo/call-function/index.html b/demo/call-function/index.html index 5c7a473dc..d8d425522 100644 --- a/demo/call-function/index.html +++ b/demo/call-function/index.html @@ -4,7 +4,7 @@ Call function - +
@@ -19,7 +19,9 @@ .then((result) => console.log(`Complex math result: ${result}`)); worker .callFunction("getRemoteData") - .then((result) => console.log(`Remote data: ${JSON.stringify(result)}`)); + .then((result) => + console.log(`Remote data: ${JSON.stringify(result)}`) + ); const addResult = await worker.callFunction("add", 40, 2); console.log(`Answer to it all: ${addResult}`); @@ -30,9 +32,9 @@ console.log(`concat([1,2,3], ["4", "5"]) is: ${result}`) ); - worker.callFunction('returnsUndefined').then(result => { - console.log(`undefined --> ${result}`) - }) + worker.callFunction("returnsUndefined").then((result) => { + console.log(`undefined --> ${result}`); + }); worker.callFunction("reject").catch((err) => console.error(err)); worker diff --git a/demo/canvas/index.html b/demo/canvas/index.html index d5c3837ae..3286c293d 100644 --- a/demo/canvas/index.html +++ b/demo/canvas/index.html @@ -6,10 +6,6 @@ - - - -
@@ -29,17 +25,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/clone-node/index.html b/demo/clone-node/index.html index 971661794..e6fdc6b77 100644 --- a/demo/clone-node/index.html +++ b/demo/clone-node/index.html @@ -6,10 +6,6 @@ - - - -
@@ -22,21 +18,5 @@ import { upgradeElement } from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - diff --git a/demo/comments/index.html b/demo/comments/index.html index d96d776e2..b47786fa1 100644 --- a/demo/comments/index.html +++ b/demo/comments/index.html @@ -6,10 +6,6 @@ - - - -
bar
@@ -17,17 +13,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/default-input-listener/index.html b/demo/default-input-listener/index.html index db4c58e2b..719c17147 100644 --- a/demo/default-input-listener/index.html +++ b/demo/default-input-listener/index.html @@ -14,10 +14,6 @@ } - - - -
@@ -31,18 +27,6 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - -

Main Thread Implementation

-
\ No newline at end of file diff --git a/demo/empty/index.html b/demo/empty/index.html index c0fdec4ee..3ba8a4f57 100644 --- a/demo/empty/index.html +++ b/demo/empty/index.html @@ -24,10 +24,6 @@ } - - - -
@@ -35,17 +31,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/hello-world/index.html b/demo/hello-world/index.html index 1c02d060b..c26b476a2 100644 --- a/demo/hello-world/index.html +++ b/demo/hello-world/index.html @@ -6,10 +6,6 @@ - - - -
@@ -21,17 +17,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/preact-dbmon/index.html b/demo/preact-dbmon/index.html index 0b2a6ec15..6192015a9 100644 --- a/demo/preact-dbmon/index.html +++ b/demo/preact-dbmon/index.html @@ -5,30 +5,14 @@ DBMON - - - - +
- - - - \ No newline at end of file diff --git a/demo/preact-map/index.html b/demo/preact-map/index.html index b8e5d34fc..d4a6d8cd5 100644 --- a/demo/preact-map/index.html +++ b/demo/preact-map/index.html @@ -6,10 +6,6 @@ - - - -
@@ -17,17 +13,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/preact-todomvc/index.html b/demo/preact-todomvc/index.html index e7cf63360..9300619bd 100644 --- a/demo/preact-todomvc/index.html +++ b/demo/preact-todomvc/index.html @@ -7,10 +7,6 @@ - - - -
@@ -23,17 +19,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - diff --git a/demo/prime-numbers/index.html b/demo/prime-numbers/index.html index ec28c2290..a9480553b 100644 --- a/demo/prime-numbers/index.html +++ b/demo/prime-numbers/index.html @@ -36,10 +36,6 @@ } - - - -
@@ -47,17 +43,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - diff --git a/demo/react-map/index.html b/demo/react-map/index.html index b8e5d34fc..d4a6d8cd5 100644 --- a/demo/react-map/index.html +++ b/demo/react-map/index.html @@ -6,10 +6,6 @@ - - - -
@@ -17,17 +13,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/svg/index.html b/demo/svg/index.html index 21bee1c19..8dc2ffea4 100644 --- a/demo/svg/index.html +++ b/demo/svg/index.html @@ -9,10 +9,6 @@ button { display: block; margin-bottom: 2em; } - - - -
@@ -20,17 +16,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/two-roots/index.html b/demo/two-roots/index.html index d54be686d..46564cf0a 100644 --- a/demo/two-roots/index.html +++ b/demo/two-roots/index.html @@ -6,10 +6,6 @@ - - - - - - - -
Hello World!spaner
@@ -35,17 +31,5 @@ import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - \ No newline at end of file diff --git a/demo/vue-todomvc/index.html b/demo/vue-todomvc/index.html index 614c42e7c..6d7a7e61c 100644 --- a/demo/vue-todomvc/index.html +++ b/demo/vue-todomvc/index.html @@ -7,7 +7,6 @@ -
@@ -65,10 +64,5 @@

todos

import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - \ No newline at end of file diff --git a/demo/webassembly/index.html b/demo/webassembly/index.html index 6476de195..80bd217ce 100644 --- a/demo/webassembly/index.html +++ b/demo/webassembly/index.html @@ -6,10 +6,6 @@ - - - -
@@ -25,17 +21,5 @@

WebAssembly

import {upgradeElement} from '/dist/main.mjs'; upgradeElement(document.getElementById('upgrade-me'), '/dist/worker/worker.mjs'); - - - - diff --git a/package.json b/package.json index 5fdb2b52b..e29492664 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@ampproject/worker-dom", "version": "0.26.0", "description": "A facsimile of a modern DOM implementation intended to run in a Web Worker.", - "main": "dist/main", + "main": "dist/main.mjs", "files": [ "dist" ], @@ -38,19 +38,15 @@ }, "devDependencies": { "@ampproject/filesize": "4.2.0", - "@ampproject/rollup-plugin-closure-compiler": "0.26.0", "@babel/cli": "7.11.6", "@babel/core": "7.11.6", - "@babel/plugin-proposal-class-properties": "7.10.4", - "@babel/plugin-proposal-object-rest-spread": "7.11.0", - "@babel/preset-env": "7.11.5", + "@rollup/plugin-babel": "5.2.0", "@rollup/plugin-replace": "2.3.3", "@types/node": "14.6.4", "@types/sinon": "9.0.5", "acorn": "8.0.1", "acorn-walk": "8.0.0", "ava": "3.12.1", - "babel-plugin-minify-replace": "0.5.0", "babel-plugin-transform-remove-console": "6.9.4", "cross-env": "7.0.2", "esm": "3.2.25", @@ -65,8 +61,6 @@ "rimraf": "3.0.2", "rollup": "2.26.11", "rollup-plugin-analyzer": "3.3.0", - "rollup-plugin-babel": "4.4.0", - "rollup-plugin-terser": "7.0.2", "sinon": "9.0.3", "sirv": "1.0.6", "tslint": "6.1.3", @@ -85,30 +79,24 @@ }, "filesize": { "track": [ - "./dist/*.(js|mjs)", - "./dist/worker/**/*.(js|mjs)", - "./dist/amp-production/**/*.(js|mjs)" + "./dist/*.mjs", + "./dist/worker/**/*.mjs", + "./dist/amp-production/**/*.mjs" ], "./dist/main.mjs": { - "brotli": "4 kB" - }, - "./dist/main.js": { - "brotli": "5 kB" + "brotli": "10 kB" }, "./dist/worker/worker.mjs": { - "brotli": "11.7 kB" - }, - "./dist/worker/worker.js": { - "brotli": "13.5 kB" + "brotli": "35 kB" }, "./dist/amp-production/main.mjs": { - "brotli": "4 kB" + "brotli": "10 kB" }, "./dist/amp-production/worker/worker.mjs": { - "brotli": "13 kB" + "brotli": "35 kB" }, "./dist/amp-production/worker/worker.nodom.mjs": { - "brotli": "2 kB" + "brotli": "5 kB" } }, "esm": { From d8746d4d8fe9f6ce1c7ce0a12b686aa20747229f Mon Sep 17 00:00:00 2001 From: Kristofer Baxter Date: Tue, 8 Sep 2020 17:57:01 -0700 Subject: [PATCH 4/4] Try using uvu for testing to avoid race conditions with ava --- .github/workflows/size.yml | 1 + demo/preact-map/package.json | 6 ++-- demo/react-map/package.json | 4 +-- package.json | 15 ++++---- src/test/comment/cloneNode.test.ts | 48 +++++++++++++------------ src/test/comment/textContent.test.ts | 54 ++++++++++++++-------------- tools/linter/package.json | 6 ++-- 7 files changed, 70 insertions(+), 64 deletions(-) diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml index 3d3900c8d..081d16cd6 100644 --- a/.github/workflows/size.yml +++ b/.github/workflows/size.yml @@ -15,4 +15,5 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: yarn install + - run: yarn build - run: yarn size \ No newline at end of file diff --git a/demo/preact-map/package.json b/demo/preact-map/package.json index 8e6af84b5..69c970f2a 100644 --- a/demo/preact-map/package.json +++ b/demo/preact-map/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "obj-str": "1.0.3", - "preact": "10.4.4" + "preact": "10.4.8" }, "devDependencies": { "@babel/core": "7.10.2", @@ -18,13 +18,13 @@ "@babel/plugin-transform-react-jsx": "7.10.1", "babel-loader": "8.1.0", "css-loader": "4.3.0", - "mini-css-extract-plugin": "0.9.0", + "mini-css-extract-plugin": "0.11.1", "style-loader": "1.2.1", "webpack": "4.44.1", "webpack-cli": "3.3.12" }, "volta": { - "node": "14.9.0", + "node": "14.10.0", "yarn": "1.22.5" } } diff --git a/demo/react-map/package.json b/demo/react-map/package.json index 4342329bc..f8db9c7dc 100644 --- a/demo/react-map/package.json +++ b/demo/react-map/package.json @@ -19,13 +19,13 @@ "@babel/plugin-transform-react-jsx": "7.10.1", "babel-loader": "8.1.0", "css-loader": "4.3.0", - "mini-css-extract-plugin": "0.9.0", + "mini-css-extract-plugin": "0.11.1", "style-loader": "1.2.1", "webpack": "4.44.1", "webpack-cli": "3.3.12" }, "volta": { - "node": "14.9.0", + "node": "14.10.0", "yarn": "1.22.5" } } diff --git a/package.json b/package.json index e29492664..890756246 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ampproject/worker-dom", - "version": "0.26.0", + "version": "0.27.1", "description": "A facsimile of a modern DOM implementation intended to run in a Web Worker.", "main": "dist/main.mjs", "files": [ @@ -18,11 +18,12 @@ "scripts": { "tsc:worker": "tsc -p src/worker-thread/tsconfig.json", "tsc:main": "tsc -p src/main-thread/tsconfig.json", - "tsc:tests": "tsc -p src/test/tsconfig.json", - "tsc:tests-main": "tsc -p src/test/main-thread/tsconfig.json", + "tsc:test:worker": "tsc -p src/test/tsconfig.json", + "tsc:test:main": "tsc -p src/test/main-thread/tsconfig.json", "clean": "rimraf output dist", - "pretest": "npm-run-all --parallel tsc:*", + "pretest": "npm-run-all --parallel tsc:* tsc:test:*", "test": "ava -v", + "tests": "uvu -r esm output/test/comment", "pre~rollup": "npm-run-all --parallel tsc:worker tsc:main", "~rollup": "rollup --config config/rollup.config.js", "lint:worker": "tslint -c config/tslint.json -p src/worker-thread/", @@ -31,9 +32,8 @@ "predemo": "cross-env DEBUG_BUNDLE=true npm-run-all ~rollup", "demo": "node -r esm demo/server.js", "build": "cross-env MINIFY_BUNDLE=true npm-run-all ~rollup", - "presize": "npm-run-all build", "size": "filesize", - "release": "np --no-2fa", + "release": "HUSKY_SKIP_HOOKS=1 np --no-2fa", "prepublishOnly": "npm-run-all clean build" }, "devDependencies": { @@ -64,7 +64,8 @@ "sinon": "9.0.3", "sirv": "1.0.6", "tslint": "6.1.3", - "typescript": "4.0.2" + "typescript": "4.0.2", + "uvu": "0.3.3" }, "lint-staged": { "*.{js,ts}": [ diff --git a/src/test/comment/cloneNode.test.ts b/src/test/comment/cloneNode.test.ts index b7a1d2521..922806c8d 100644 --- a/src/test/comment/cloneNode.test.ts +++ b/src/test/comment/cloneNode.test.ts @@ -14,18 +14,19 @@ * limitations under the License. */ -import anyTest, { TestInterface } from 'ava'; -import { Element } from '../../worker-thread/dom/Element'; -import { Comment } from '../../worker-thread/dom/Comment'; +import { suite, Context } from 'uvu'; +import * as assert from 'uvu/assert'; import { TransferrableKeys } from '../../transfer/TransferrableKeys'; import { createTestingDocument } from '../DocumentCreation'; +import { Element } from '../../worker-thread/dom/Element'; +import { Comment } from '../../worker-thread/dom/Comment'; -const test = anyTest as TestInterface<{ - parent: Element; - comment: Comment; -}>; +const test = suite('cloneNode', { + parent: Element, + comment: Comment, +}); -test.beforeEach((t) => { +test.before.each((context) => { const document = createTestingDocument(); const parent = document.createElement('div'); const comment = document.createComment('Super Comment'); @@ -33,29 +34,30 @@ test.beforeEach((t) => { parent.appendChild(comment); document.body.appendChild(parent); - t.context = { - parent, - comment, - }; + context.parent = parent; + context.comment = comment; }); -test('cloneNode should create a new node with the same tagName', (t) => { - const { comment } = t.context; +test('cloneNode should create a new node with the same tagName', (context) => { + const { comment } = context; - t.is(comment.cloneNode().tagName, comment.tagName); + assert.is(comment.cloneNode().tagName, comment.tagName); }); -test('cloneNode should create a new node with a different index', (t) => { - const { comment } = t.context; +test('cloneNode should create a new node with a different index', (context) => { + const { comment } = context; + const clone = comment.cloneNode(); - t.not(comment.cloneNode()[TransferrableKeys.index], comment[TransferrableKeys.index]); + assert.not.equal(clone[TransferrableKeys.index], comment[TransferrableKeys.index]); }); -test('cloneNode should create a new node with the same children when the deep flag is set', (t) => { - const { parent, comment } = t.context; +test('cloneNode should create a new node with the same children when the deep flag is set', (context) => { + const { parent, comment } = context; const clone = parent.cloneNode(true); - t.is(parent.childNodes.length, clone.childNodes.length); - t.is(comment.tagName, clone.childNodes[0].tagName); - t.is(comment.textContent, clone.childNodes[0].textContent); + assert.is(parent.childNodes.length, clone.childNodes.length); + assert.is(comment.tagName, clone.childNodes[0].tagName); + assert.is(comment.textContent, clone.childNodes[0].textContent); }); + +test.run(); diff --git a/src/test/comment/textContent.test.ts b/src/test/comment/textContent.test.ts index e88334992..7a1318502 100644 --- a/src/test/comment/textContent.test.ts +++ b/src/test/comment/textContent.test.ts @@ -14,47 +14,49 @@ * limitations under the License. */ -import anyTest, { TestInterface } from 'ava'; -import { Comment } from '../../worker-thread/dom/Comment'; +import { suite, Context } from 'uvu'; +import * as assert from 'uvu/assert'; import { createTestingDocument } from '../DocumentCreation'; +import { Document } from '../../worker-thread/dom/Document'; -const test = anyTest as TestInterface<{ - comment: Comment; -}>; - -test.beforeEach((t) => { - const document = createTestingDocument(); +const test = suite('textContent', { + document: Document, +}); - t.context = { - comment: document.createComment('default value'), - }; +test.before.each((context) => { + context.document = createTestingDocument(); }); -test('get textContent', (t) => { - const { comment } = t.context; +test('get textContent', (context) => { + const { document } = context; + const comment = document.createComment('default value'); - t.is(comment.textContent, 'default value'); + assert.is(comment.textContent, 'default value'); }); -test('set textContent', (t) => { - const { comment } = t.context; +test('set textContent', (context) => { + const { document } = context; + const comment = document.createComment('default value'); - t.is(comment.textContent, 'default value'); + assert.is(comment.textContent, 'default value'); comment.textContent = 'new value'; - t.is(comment.textContent, 'new value'); + assert.is(comment.textContent, 'new value'); }); -test('textContent matches data', (t) => { - const { comment } = t.context; +test('textContent matches data', (context) => { + const { document } = context; + const comment = document.createComment('default value'); - t.is(comment.data, 'default value'); - t.is(comment.textContent, 'default value'); + assert.is(comment.data, 'default value'); + assert.is(comment.textContent, 'default value'); comment.data = 'data setter'; - t.is(comment.data, 'data setter'); - t.is(comment.textContent, 'data setter'); + assert.is(comment.data, 'data setter'); + assert.is(comment.textContent, 'data setter'); comment.textContent = 'textContent setter'; - t.is(comment.data, 'textContent setter'); - t.is(comment.textContent, 'textContent setter'); + assert.is(comment.data, 'textContent setter'); + assert.is(comment.textContent, 'textContent setter'); }); + +test.run(); diff --git a/tools/linter/package.json b/tools/linter/package.json index 40962a7e4..43ad6e0bf 100644 --- a/tools/linter/package.json +++ b/tools/linter/package.json @@ -23,9 +23,9 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "ava": "3.8.2", + "ava": "3.12.1", "esm": "3.2.25", - "lint-staged": "10.2.9", + "lint-staged": "10.3.0", "npm-run-all": "4.1.5", "prettier": "2.1.1", "rimraf": "3.0.2", @@ -43,7 +43,7 @@ ] }, "volta": { - "node": "14.9.0", + "node": "14.10.0", "yarn": "1.22.5" } }