${parseButtons(buttons)}
@@ -130,8 +126,8 @@ function parseButtons(buttons) {
}
function showDialog(title, msg, value, buttons, options) {
- const ok = store();
- const cancel = store();
+ const ok = fullstore();
+ const cancel = fullstore();
const closeButtons = [
'cancel',
@@ -170,6 +166,7 @@ function showDialog(title, msg, value, buttons, options) {
for (const event of ['click', 'contextmenu'])
dialog.addEventListener(event, (e) => {
e.stopPropagation();
+
for (const el of find(dialog, ['ok', 'input']))
el.focus();
});
@@ -184,21 +181,25 @@ function showDialog(title, msg, value, buttons, options) {
function keyDown_(dialog, ok, cancel, event) {
const KEY = {
- ENTER : 13,
- ESC : 27,
- TAB : 9,
- LEFT : 37,
- UP : 38,
- RIGHT : 39,
- DOWN : 40,
+ ENTER: 13,
+ ESC: 27,
+ TAB: 9,
+ LEFT: 37,
+ UP: 38,
+ RIGHT: 39,
+ DOWN: 40,
};
const {keyCode} = event;
const el = event.target;
- const namesAll = ['ok', 'cancel', 'input'];
- const names = find(dialog, namesAll)
- .map(getDataName);
+ const namesAll = [
+ 'ok',
+ 'cancel',
+ 'input',
+ ];
+
+ const names = find(dialog, namesAll).map(getDataName);
switch(keyCode) {
case KEY.ENTER:
@@ -220,9 +221,16 @@ function keyDown_(dialog, ok, cancel, event) {
break;
default:
- ['left', 'right', 'up', 'down'].filter((name) => keyCode === KEY[name.toUpperCase()]).forEach(() => {
- changeButtonFocus(dialog, names);
- });
+ [
+ 'left',
+ 'right',
+ 'up',
+ 'down',
+ ]
+ .filter((name) => keyCode === KEY[name.toUpperCase()])
+ .forEach(() => {
+ changeButtonFocus(dialog, names);
+ });
break;
}
@@ -295,14 +303,14 @@ function closeDialog(el, dialog, ok, cancel) {
let value = null;
for (const el of find(dialog, ['input'])) {
- value = el.value;
+ ({value} = el);
}
ok(value);
remove(dialog);
}
-const query = currify((element, name) => element.querySelector(`[data-name="js-${ name }"]`));
+const query = currify((element, name) => element.querySelector(`[data-name="js-${name}"]`));
function find(element, names) {
const elements = names
@@ -324,4 +332,3 @@ function remove(dialog) {
if (parentElement)
parentElement.removeChild(dialog);
}
-
diff --git a/lib/smalltalk.native.js b/lib/smalltalk.native.js
index a5bbeb9..d6acf8a 100644
--- a/lib/smalltalk.native.js
+++ b/lib/smalltalk.native.js
@@ -1,8 +1,8 @@
-'use strict';
+import '../css/smalltalk.css';
-require('../css/smalltalk.css');
-
-exports.alert = (title, message) => {
+export const alert = (title, message, overrides = {}) => {
+ const {alert = globalThis.alert} = overrides;
+
const promise = new Promise((resolve) => {
alert(message);
resolve();
@@ -11,8 +11,10 @@ exports.alert = (title, message) => {
return promise;
};
-exports.prompt = (title, message, value, options) => {
+export const prompt = (title, message, value, options, overrides = {}) => {
+ const {prompt = globalThis.prompt} = overrides;
const o = options;
+
const promise = new Promise((resolve, reject) => {
const noCancel = o && !o.cancel;
const result = prompt(message, value);
@@ -29,9 +31,12 @@ exports.prompt = (title, message, value, options) => {
return promise;
};
-exports.confirm = (title, message, options) => {
+export const confirm = (title, message, options, overrides = {}) => {
+ const {confirm = globalThis.confirm} = overrides;
+
const o = options;
const noCancel = o && !o.cancel;
+
const promise = new Promise((resolve, reject) => {
const is = confirm(message);
@@ -46,4 +51,3 @@ exports.confirm = (title, message, options) => {
return promise;
};
-
diff --git a/package.json b/package.json
index 5501812..4e51e4d 100644
--- a/package.json
+++ b/package.json
@@ -1,18 +1,16 @@
{
"name": "smalltalk",
- "version": "4.1.1",
- "type": "commonjs",
- "commitType": "colon",
+ "version": "5.0.1",
+ "type": "module",
"description": "Promise-based Alert, Confirm and Prompt replacement",
"homepage": "http://github.com/coderaiser/smalltalk",
"repository": {
"type": "git",
- "url": "git://github.com/coderaiser/smalltalk.git"
+ "url": "git+https://github.com/coderaiser/smalltalk.git"
},
"main": "lib/smalltalk.js",
"exports": {
- ".": "./lib/smalltalk",
- "./bundle": "./dist/smalltalk.min.js"
+ ".": "./lib/smalltalk.js"
},
"scripts": {
"watch": "madrun watch",
@@ -48,34 +46,34 @@
"url": "https://github.com/coderaiser/smalltalk/issues"
},
"devDependencies": {
- "auto-globals": "^2.0.0",
+ "auto-globals": "^4.0.1",
"autoprefixer": "^10.0.1",
- "c8": "^7.11.3",
"clean-css-loader": "^4.1.1",
- "coveralls": "^3.0.0",
- "css-loader": "^6.7.1",
+ "css-loader": "^7.1.3",
"css-modules-require-hook": "^4.2.3",
- "eslint": "^8.19.0",
- "eslint-plugin-node": "^11.0.0",
- "eslint-plugin-putout": "^15.8.0",
- "madrun": "^9.0.5",
- "nodemon": "^2.0.1",
- "putasset": "^6.0.0",
- "putout": "^26.24.0",
- "style-loader": "^3.3.1",
- "supertape": "^7.6.0",
+ "eslint": "^10.0.3",
+ "eslint-plugin-n": "^17.23.2",
+ "eslint-plugin-putout": "^31.1.1",
+ "madrun": "^13.0.1",
+ "nodemon": "^3.0.2",
+ "postcss": "^8.4.32",
+ "putasset": "^7.0.0",
+ "putout": "^42.2.3",
+ "style-loader": "^4.0.0",
+ "superc8": "^12.3.1",
+ "supertape": "^12.2.0",
"terser-webpack-plugin": "^5.0.0",
"try-to-tape": "^1.1.0",
"url-loader": "^4.0.0",
- "version-io": "^4.0.1",
+ "version-io": "^6.1.2",
"webpack": "^5.1.3",
- "webpack-cli": "^4.0.0",
+ "webpack-cli": "^7.0.2",
"wraptile": "^3.0.0"
},
"dependencies": {
"@cloudcmd/create-element": "^2.0.0",
"currify": "^4.0.0",
- "fullstore": "^3.0.0"
+ "fullstore": "^4.0.0"
},
"publishConfig": {
"access": "public"
diff --git a/test/smalltalk.js b/test/smalltalk.js
index c5b64a2..5daa769 100644
--- a/test/smalltalk.js
+++ b/test/smalltalk.js
@@ -1,26 +1,19 @@
-'use strict';
-
-const path = require('path');
-const fs = require('fs');
-
-require('css-modules-require-hook/preset');
-
-const autoGlobals = require('auto-globals');
-const tape = require('supertape');
-const stub = require('@cloudcmd/stub');
-const currify = require('currify');
-const wraptile = require('wraptile');
-
-global.window = {};
+import process from 'node:process';
+import fs from 'node:fs';
+import autoGlobals from 'auto-globals';
+import {test as tape} from 'supertape';
+import currify from 'currify';
+import wraptile from 'wraptile';
+import * as smalltalk from '../lib/smalltalk.js';
+globalThis.window = {};
const {UPDATE_FIXTURE} = process.env;
-
-const smalltalk = require('../lib/smalltalk');
const noop = () => {};
const isUpdateFixtures = UPDATE_FIXTURE === 'true' || UPDATE_FIXTURE === '1';
const {create} = autoGlobals;
const test = autoGlobals(tape);
-const fixtureDir = path.join(__dirname, 'fixture');
+const fixtureDir = new URL('fixture', import.meta.url).pathname;
+const {stub} = tape;
const writeFixture = (name, data) => {
return fs.writeFileSync(`${fixtureDir}/${name}.html`, data);
@@ -28,6 +21,7 @@ const writeFixture = (name, data) => {
const readFixture = (name) => {
const fn = () => fs.readFileSync(`${fixtureDir}/${name}.html`, 'utf8');
+
fn.update = !isUpdateFixtures ? noop : currify(writeFixture, name);
return fn;
@@ -88,16 +82,15 @@ test('smalltalk: alert: click', (t, {document}) => {
createElement.returns(el);
smalltalk.alert('title', 'message');
- t.equal(ok.addEventListener.args.pop()[0], 'click', 'should set click listener');
+ const [result] = ok.addEventListener.args.pop();
+
+ t.equal(result, 'click', 'should set click listener');
t.end();
});
test('smalltalk: alert: close: remove', (t, {document}) => {
const parentElement = create();
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const el = {
...create(),
@@ -125,15 +118,16 @@ test('smalltalk: alert: close: remove', (t, {document}) => {
target: ok,
});
- t.equal(parentElement.removeChild.args.pop().pop(), el, 'should find smalltalk');
+ t.equal(parentElement
+ .removeChild
+ .args
+ .pop()
+ .pop(), el, 'should find smalltalk');
t.end();
});
test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const parentElement = create();
@@ -157,7 +151,11 @@ test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {
smalltalk.alert('title', 'message');
- const [, keydown] = el.addEventListener.args.filter(([event]) => event === 'keydown').pop();
+ const [, keydown] = el
+ .addEventListener
+ .args
+ .filter(([event]) => event === 'keydown')
+ .pop();
const event = {
stopPropagation: stub(),
@@ -170,10 +168,7 @@ test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {
});
test('smalltalk: alert: click: stopPropagation: called', (t, {document}) => {
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const parentElement = create();
const el = {
@@ -196,10 +191,14 @@ test('smalltalk: alert: click: stopPropagation: called', (t, {document}) => {
smalltalk.alert('title', 'message');
- const [, click] = el.addEventListener.args.filter((a) => {
+ const [, click] = el
+ .addEventListener
+ .args
+ .filter((a) => {
const [event] = a;
return event === 'click';
- }).pop();
+ })
+ .pop();
const event = {
stopPropagation: stub(),
@@ -243,7 +242,9 @@ test('smalltalk: alert: keydown: tab: preventDefault', (t, {document}) => {
smalltalk.alert('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -270,6 +271,7 @@ test('smalltalk: alert: keydown: tab: active name', (t, {document}) => {
} = document;
const parentElement = create();
+
const el = {
...create(),
parentElement,
@@ -286,7 +288,9 @@ test('smalltalk: alert: keydown: tab: active name', (t, {document}) => {
smalltalk.alert('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -314,6 +318,7 @@ test('smalltalk: alert: keydown: left: focus', (t) => {
} = document;
const parentElement = create();
+
const el = {
...create(),
parentElement,
@@ -335,7 +340,9 @@ test('smalltalk: alert: keydown: left: focus', (t) => {
smalltalk.alert('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -355,10 +362,7 @@ test('smalltalk: alert: keydown: left: focus', (t) => {
});
test('smalltalk: alert: click: focus', (t, {document}) => {
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const parentElement = create();
const el = {
@@ -381,7 +385,9 @@ test('smalltalk: alert: click: focus', (t, {document}) => {
smalltalk.alert('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'click')
.pop();
@@ -454,7 +460,8 @@ test('smalltalk: confirm: click on close', (t) => {
document.createElement.returns(el);
document.querySelector.returns(el);
- smalltalk.confirm('title', 'message')
+ smalltalk
+ .confirm('title', 'message')
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -500,7 +507,9 @@ test('smalltalk: confirm: keydown: left: active name', (t, {document}) => {
smalltalk.confirm('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -559,7 +568,9 @@ test('smalltalk: confirm: keydown: left: active name: cancel', (t, {document}) =
smalltalk.confirm('title', 'message');
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -580,10 +591,7 @@ test('smalltalk: confirm: keydown: left: active name: cancel', (t, {document}) =
test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {
const parentElement = create();
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const el = {
...create(),
@@ -603,13 +611,16 @@ test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);
- smalltalk.confirm('title', 'message')
+ smalltalk
+ .confirm('title', 'message')
.catch((e) => {
t.ok(e, 'should reject');
t.end();
});
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -627,10 +638,7 @@ test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {
test('smalltalk: confirm: keydown: enter', (t, {document}) => {
const parentElement = create();
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const el = {
...create(),
@@ -650,13 +658,16 @@ test('smalltalk: confirm: keydown: enter', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);
- smalltalk.confirm('title', 'message')
+ smalltalk
+ .confirm('title', 'message')
.then(() => {
t.pass('should resolve');
t.end();
});
- const [, keydown] = el.addEventListener.args
+ const [, keydown] = el
+ .addEventListener
+ .args
.filter(([event]) => event === 'keydown')
.pop();
@@ -736,10 +747,7 @@ test('smalltalk: prompt: no value', (t, {document}) => {
});
test('smalltalk: prompt: click on ok', (t, {document}) => {
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const dataName = (a) => `[data-name="js-${a}"]`;
@@ -769,7 +777,8 @@ test('smalltalk: prompt: click on ok', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);
- smalltalk.prompt('title', 'message', value)
+ smalltalk
+ .prompt('title', 'message', value)
.then((result) => {
t.equal(result, value, 'should return value');
t.end();
@@ -784,12 +793,10 @@ test('smalltalk: prompt: click on ok', (t, {document}) => {
test('smalltalk: prompt: click on cancel', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const value = 'hello';
+
const input = {
...create(),
value,
@@ -815,7 +822,8 @@ test('smalltalk: prompt: click on cancel', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);
- smalltalk.prompt('title', 'message', value)
+ smalltalk
+ .prompt('title', 'message', value)
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -830,12 +838,10 @@ test('smalltalk: prompt: click on cancel', (t, {document}) => {
test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const value = 'hello';
+
const input = {
...create(),
value,
@@ -864,7 +870,10 @@ test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {
const fail = t.fail.bind(t);
const end = t.end.bind(t);
- smalltalk.prompt('title', 'message', value, {cancel: false})
+ smalltalk
+ .prompt('title', 'message', value, {
+ cancel: false,
+ })
.then(wraptile(fail, 'should not pass'))
.catch(wraptile(fail, 'should not reject'))
.then(end);
@@ -881,12 +890,10 @@ test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {
test('smalltalk: prompt: click on cancel: options: no cancel', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
- const {
- createElement,
- querySelector,
- } = document;
+ const {createElement, querySelector} = document;
const value = 'hello';
+
const input = {
...create(),
value,
@@ -912,7 +919,8 @@ test('smalltalk: prompt: click on cancel: options: no cancel', (t, {document}) =
createElement.returns(el);
querySelector.returns(el);
- smalltalk.prompt('title', 'message', value, {})
+ smalltalk
+ .prompt('title', 'message', value, {})
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -976,6 +984,7 @@ test('smalltalk: progress: setProgress', (t, {document}) => {
test('smalltalk: progress: setProgress: 100', (t, {document}) => {
const valueEl = create();
+
valueEl.parentElement = create();
document.querySelector.returns(valueEl);
@@ -996,6 +1005,7 @@ test('smalltalk: progress: setProgress: 100', (t, {document}) => {
test('smalltalk: progress: remove', (t, {document}) => {
const valueEl = create();
+
valueEl.parentElement = create();
document.querySelector.returns(valueEl);
@@ -1016,4 +1026,3 @@ test('smalltalk: progress: remove', (t, {document}) => {
t.calledWith(removeChild, [el], 'should call removeChild');
t.end();
});
-
diff --git a/test/smalltalk.native.js b/test/smalltalk.native.js
index 8acaba3..4e104c0 100644
--- a/test/smalltalk.native.js
+++ b/test/smalltalk.native.js
@@ -1,88 +1,73 @@
-'use strict';
+import {test, stub} from 'supertape';
+import {tryToCatch} from 'try-to-catch';
+import * as smalltalk from '../lib/smalltalk.native.js';
-const {
- test,
- stub,
-} = require('supertape');
+globalThis.window = {};
-const smalltalk = require('../lib/smalltalk.native');
-
-global.window = {};
-
-test('smalltalk.native: Promise', (t) => {
- global.window.Promise = null;
- reload();
-
- t.pass('load with no Promise support');
- t.end();
-});
-
-test('smalltalk.native: alert', (t) => {
+test('smalltalk.native: alert', async (t) => {
const alert = stub();
- global.alert = alert;
- smalltalk.alert('title', 'message');
+ await smalltalk.alert('title', 'message', {
+ alert,
+ });
t.calledWith(alert, ['message'], 'alert should have been called with message');
t.end();
});
-test('smalltalk.native: alert: result', (t) => {
- global.alert = stub();
+test('smalltalk.native: alert: result', async (t) => {
+ const alert = stub();
- smalltalk.alert('title', 'message').then(() => {
- t.pass('promise should have been resolved');
- t.end();
- })
- .catch((e) => {
- t.fail(`should not reject ${e.message}`);
- });
+ await smalltalk.alert('title', 'message', {
+ alert,
+ });
+
+ t.pass('promise should have been resolved');
+ t.end();
});
-test('smalltalk.native: confirm', (t) => {
+test('smalltalk.native: confirm', async (t) => {
const confirm = stub().returns(false);
- global.confirm = confirm;
- smalltalk.confirm('title', 'message')
- .catch(() => {
- t.calledWith(confirm, ['message'], 'confirm should have been called with message');
- t.end();
- });
+ await tryToCatch(smalltalk.confirm, 'title', 'message', null, {
+ confirm,
+ });
+
+ t.calledWith(confirm, ['message'], 'confirm should have been called with message');
+ t.end();
});
test('smalltalk.native: confirm: result: ok', (t) => {
- global.confirm = stub().returns(true);
+ globalThis.confirm = stub().returns(true);
- smalltalk.confirm('title', 'message').then(() => {
- t.pass('should resolve');
- t.end();
- })
- .catch((e) => {
- t.notOk(e, 'should not reject');
- });
+ smalltalk.confirm('title', 'message');
+
+ t.pass('should resolve');
+ t.end();
});
-test('smalltalk.native: confirm: result: cancel', (t) => {
- global.confirm = stub().returns(false);
+test('smalltalk.native: confirm: result: cancel', async (t) => {
+ globalThis.confirm = stub().returns(false);
- smalltalk.confirm('title', 'message').then(() => {
- t.fail('should not resolve');
- t.end();
- })
- .catch((e) => {
- t.ok(e, 'should reject');
- });
+ const [e] = await tryToCatch(smalltalk.confirm, 'title', 'message');
+
+ t.ok(e, 'should reject');
+ t.end();
});
test('smalltalk.native: confirm: options: cancel', (t) => {
- global.confirm = stub().returns(false);
+ globalThis.confirm = stub().returns(false);
const cancel = false;
- smalltalk.confirm('title', 'message', {cancel}).then(() => {
- t.fail('should not resolve');
- t.end();
- })
+ smalltalk
+ .confirm('title', 'message', {
+ cancel,
+ })
+ .then(() => {
+ t.fail('should not resolve');
+ t.end();
+ })
.catch(() => {
t.fail('should not reject');
});
@@ -92,59 +77,47 @@ test('smalltalk.native: confirm: options: cancel', (t) => {
test('smalltalk.native: prompt', (t) => {
const prompt = stub();
- global.prompt = prompt;
- smalltalk.prompt('title', 'message', 'value');
+ smalltalk.prompt('title', 'message', 'value', null, {
+ prompt,
+ });
t.calledWith(prompt, ['message', 'value'], 'prompt should have been called with message');
t.end();
});
test('smalltalk.native: prompt: result: ok', (t) => {
- global.prompt = stub().returns('hello');
+ globalThis.prompt = stub().returns('hello');
- smalltalk.prompt('title', 'message', 'value').then((value) => {
- t.equal(value, 'hello', 'should resolve value');
- t.end();
- })
+ smalltalk
+ .prompt('title', 'message', 'value')
+ .then((value) => {
+ t.equal(value, 'hello', 'should resolve value');
+ t.end();
+ })
.catch((e) => {
t.fail(`should not reject ${e.message}`);
});
});
-test('smalltalk.native: prompt: result: cancel', (t) => {
- global.prompt = stub().returns(null);
+test('smalltalk.native: prompt: result: cancel', async (t) => {
+ const prompt = stub().returns(null);
- smalltalk.prompt('title', 'message', 'value').then(() => {
- t.fail('should not resolve');
- t.end();
- })
- .catch((e) => {
- t.ok(e, 'should reject');
- });
+ await tryToCatch(smalltalk.prompt, 'title', 'message', 'value', null, {
+ prompt,
+ });
+
+ t.pass('should reject');
+ t.end();
});
test('smalltalk.native: prompt: options: cancel', (t) => {
- global.prompt = stub().returns(null);
-
- smalltalk.prompt('title', 'message', 'value', {
- cancel: false,
- }).then(() => {
- t.fail('should not resolve');
- t.end();
- })
- .catch((e) => {
- t.fail(`should not reject ${e.message}`);
- });
+ const prompt = stub().returns(null);
+
+ smalltalk.prompt('title', 'message', 'value', {cancel: false}, {
+ prompt,
+ });
t.pass('should do nothing');
+ t.end();
});
-
-function reload() {
- clean();
- return require('../lib/smalltalk.native');
-}
-
-function clean() {
- delete require.cache[require.resolve('../lib/smalltalk.native')];
-}
diff --git a/webpack.config.js b/webpack.config.js
index ebf11a7..f12ab59 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,8 +1,9 @@
-'use strict';
-
-const path = require('path');
-const TerserPlugin = require('terser-webpack-plugin');
+import path, {dirname} from 'node:path';
+import {fileURLToPath} from 'node:url';
+import TerserPlugin from 'terser-webpack-plugin';
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = dirname(__filename);
const dir = './lib';
const dist = path.resolve(__dirname, 'dist');
@@ -10,7 +11,11 @@ const devtool = 'source-map';
const rules = [{
test: /\.css$/,
- use: ['style-loader', 'css-loader', 'clean-css-loader'],
+ use: [
+ 'style-loader',
+ 'css-loader',
+ 'clean-css-loader',
+ ],
}, {
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,
use: [{
@@ -32,7 +37,7 @@ const optimization = {
const filename = `[name].min.js`;
-module.exports = {
+export default {
devtool,
entry: {
'smalltalk': `${dir}/smalltalk.js`,