Skip to content

Commit c8268c2

Browse files
committed
feat: migrate from commonjs to module
1 parent 5617355 commit c8268c2

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-22.04
1111
strategy:
1212
fail-fast: false
1313
matrix:

jest-puppeteer.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
module.exports = {
1+
/** @type {import('jest-environment-puppeteer').JestPuppeteerConfig} */
2+
const config = {
23
launch: {
34
headless: process.env.CI === "true",
45
},
@@ -8,3 +9,5 @@ module.exports = {
89
launchTimeout: 180000,
910
},
1011
};
12+
13+
export default config;

jest.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
module.exports = {
1+
/** @type {import('jest').Config} */
2+
const config = {
23
preset: "jest-puppeteer",
34
testMatch: [
45
"**/tests/**/*.js",
56
],
67
};
8+
9+
export default config;

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "openscad-playground",
33
"version": "0.1.0",
44
"private": true,
5+
"type": "module",
56
"homepage": "https://ochafik.com/openscad2/",
67
"dependencies": {
78
"@gltf-transform/core": "^4.1.1",
@@ -63,7 +64,7 @@
6364
"@types/react-dom": "^18.3.5",
6465
"@types/uzip": "^0.20201231.2",
6566
"@types/web": "^0.0.140",
66-
"copy-webpack-plugin": "^11.0.0",
67+
"copy-webpack-plugin": "^12.0.2",
6768
"css-loader": "^7.1.2",
6869
"jest": "^29.7.0",
6970
"jest-puppeteer": "^11.0.0",

webpack.config.js

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
const webpack = require('webpack');
2-
const CopyPlugin = require("copy-webpack-plugin");
3-
const WorkboxPlugin = require('workbox-webpack-plugin');
4-
const path = require('path');
5-
const packageConfig = require('./package.json');
1+
import CopyPlugin from 'copy-webpack-plugin';
2+
import WorkboxPlugin from 'workbox-webpack-plugin';
3+
import webpack from 'webpack';
4+
import packageConfig from './package.json' with {type: 'json'};
5+
6+
import path, {dirname} from 'path';
7+
import {fileURLToPath} from 'url';
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = dirname(__filename);
611

712
const LOCAL_URL = process.env.LOCAL_URL ?? 'http://localhost:4000/';
813
const PUBLIC_URL = process.env.PUBLIC_URL ?? packageConfig.homepage;
914
const isDev = process.env.NODE_ENV !== 'production';
1015

11-
module.exports = [
16+
17+
/** @type {import('webpack').Configuration[]} */
18+
const config = [
1219
{
1320
entry: './src/index.tsx',
1421
devtool: isDev ? 'source-map' : 'nosources-source-map',
@@ -38,7 +45,7 @@ module.exports = [
3845
{
3946
test: /\.css$/i,
4047
use: [
41-
"style-loader",
48+
'style-loader',
4249
{
4350
loader: 'css-loader',
4451
options:{url: false},
@@ -47,7 +54,7 @@ module.exports = [
4754
},
4855
// {
4956
// test: /\.(png|gif|woff|woff2|eot|ttf|svg)$/,
50-
// loader: "url-loader?limit=100000"
57+
// loader: 'url-loader?limit=100000'
5158
// },
5259
],
5360
},
@@ -59,7 +66,7 @@ module.exports = [
5966
path: path.resolve(__dirname, 'dist'),
6067
},
6168
devServer: {
62-
static: path.join(__dirname, "dist"),
69+
static: path.join(__dirname, 'dist'),
6370
compress: true,
6471
port: 4000,
6572
},
@@ -74,9 +81,9 @@ module.exports = [
7481
/\.map$/,
7582
/^manifest.*\.js$/,
7683
],
77-
// these options encourage the ServiceWorkers to get in there fast
78-
// and not allow any straggling "old" SWs to hang around
79-
swDest: path.join(__dirname, "dist", 'sw.js'),
84+
// these options encourage the ServiceWorkers to get in there fast
85+
// and not allow any straggling 'old' SWs to hang around
86+
swDest: path.join(__dirname, 'dist', 'sw.js'),
8087
maximumFileSizeToCacheInBytes: 200 * 1024 * 1024,
8188
clientsClaim: true,
8289
skipWaiting: true,
@@ -95,16 +102,16 @@ module.exports = [
95102
] : []),
96103
new CopyPlugin({
97104
patterns: [
98-
{
105+
{
99106
from: path.resolve(__dirname, 'public'),
100107
toType: 'dir',
101108
},
102-
{
109+
{
103110
from: path.resolve(__dirname, 'node_modules/primeicons/fonts'),
104111
to: path.resolve(__dirname, 'dist/fonts'),
105112
toType: 'dir',
106113
},
107-
{
114+
{
108115
from: path.resolve(__dirname, 'src/wasm/openscad.js'),
109116
from: path.resolve(__dirname, 'src/wasm/openscad.wasm'),
110117
},
@@ -177,3 +184,5 @@ module.exports = [
177184
],
178185
},
179186
];
187+
188+
export default config;

0 commit comments

Comments
 (0)