Skip to content

Commit

Permalink
feat!: migrate to native esm
Browse files Browse the repository at this point in the history
- use "type": "module" in all packages
- convert commonjs to esm
- adjust imports to contain extension for native node compatibility
- move ci to Node 22
- upgrade @types/node to v22
- upgrade esm-only deps and regenerate lock file
  • Loading branch information
AviVahl committed Dec 21, 2024
1 parent cd8946b commit c5e6885
Show file tree
Hide file tree
Showing 36 changed files with 230 additions and 222 deletions.
2 changes: 1 addition & 1 deletion empty-object.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = {};
export {};
14 changes: 7 additions & 7 deletions esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// @ts-check

import { fileURLToPath } from 'node:url';
import { builtinModules as nativeNodeApis } from 'node:module';

// Used as a polyfill for node apis when they aren't available.
// The key is the node api name and the value is the stand-in object.
const emptyModulePath = require.resolve(`./empty-object.js`);
const utilModulePath = require.resolve(`./micro-util-nofill.js`);
const emptyModulePath = fileURLToPath(import.meta.resolve(`./empty-object.js`));
const utilModulePath = fileURLToPath(import.meta.resolve(`./micro-util-nofill.js`));

// get all native node apis

const nativeNodeApis = require('module').builtinModules;

/** @type {Record<string, string>} */
const alias = {};
for (const nodeApi of nativeNodeApis) {
if (nodeApi === 'util') {
Expand All @@ -21,8 +22,7 @@ for (const nodeApi of nativeNodeApis) {
}

/** @type {import('esbuild').BuildOptions} */
module.exports = {
plugins: [],
export default {
alias,
loader: {
'.jpg': 'file',
Expand Down
178 changes: 84 additions & 94 deletions package-lock.json

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

Loading

0 comments on commit c5e6885

Please sign in to comment.