Migrate to JavaScript modules

This commit is contained in:
Sam Atkins 2024-03-20 14:10:39 +00:00
parent ccdcead5e9
commit 5f18032737
5 changed files with 20 additions and 17 deletions

View File

@ -1,3 +1,3 @@
const {build} = require("./utils.js") import { build } from "./utils.js"
build(); build();

View File

@ -1,8 +1,8 @@
const express = require("express"); import express from "express";
const { generateDevHtml, build } = require("./utils.js"); import { generateDevHtml, build } from "./utils.js";
const { argv } = require('node:process'); import { argv } from 'node:process';
const chalk = require('chalk'); import chalk from 'chalk';
const dotenv = require('dotenv'); import dotenv from 'dotenv';
dotenv.config(); dotenv.config();
const app = express(); const app = express();
@ -55,4 +55,4 @@ if(env === "dev"){
app.use(express.static('./src/')); app.use(express.static('./src/'));
} }
module.exports = app; export { app };

View File

@ -5,6 +5,7 @@
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"description": "Desktop environment in the browser!", "description": "Desktop environment in the browser!",
"homepage": "https://puter.com", "homepage": "https://puter.com",
"type": "module",
"directories": { "directories": {
"lib": "lib" "lib": "lib"
}, },

View File

@ -51,4 +51,4 @@ const js_paths = [
`/i18n/i18n.js`, `/i18n/i18n.js`,
] ]
module.exports = { lib_paths, css_paths, js_paths } export { lib_paths, css_paths, js_paths };

View File

@ -16,15 +16,17 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { encode } from 'html-entities';
import fs from 'fs';
import path from 'path';
import webpack from 'webpack';
import CleanCSS from 'clean-css';
import uglifyjs from 'uglify-js';
import { lib_paths, css_paths, js_paths } from './src/static-assets.js';
import { fileURLToPath } from 'url';
// Polyfill __dirname, which doesn't exist in modules mode
const {encode} = require('html-entities'); const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const CleanCSS = require('clean-css');
const uglifyjs = require('uglify-js');
const {lib_paths, css_paths, js_paths} = require('./src/static-assets.js');
/** /**
* Builds the application by performing various tasks such as cleaning the distribution directory, * Builds the application by performing various tasks such as cleaning the distribution directory,
@ -348,4 +350,4 @@ function generateDevHtml(options){
} }
// export // export
module.exports = {generateDevHtml, build}; export { generateDevHtml, build };