fix: need to update build configuration, and use a custom rollup

This commit is contained in:
Derrick Hammer 2023-07-04 00:56:03 -04:00
parent 7697a03722
commit 0f9318306f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
5 changed files with 65 additions and 54 deletions

View File

@ -3,6 +3,7 @@
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"official": true
"official": true,
"browser": true
}
}

View File

@ -23,10 +23,5 @@
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-discovery-irc.git"
},
"browser": {
"crypto": false,
"net": "./build/net.js",
"tls": "./build/net.js"
}
}

View File

@ -1,12 +0,0 @@
diff --git a/dist/src/irc.js b/dist/src/irc.js
index fd7a55d6bb09a961921e58e6bff1a7028c61bb47..c96cbca5e904b5ba0312d7ae273e537e66e22fb9 100644
--- a/dist/src/irc.js
+++ b/dist/src/irc.js
@@ -9,6 +9,7 @@ import defaultsdeep from 'lodash.defaultsdeep';
import { TypedEmitter } from 'tiny-typed-emitter';
import { CyclingPingTimer } from './cyclingPingTimer.js';
import { parseMessage } from './parseMessage.js';
+import { Buffer } from 'buffer';
const log = debug('irc');
const lineDelimiter = new RegExp(/\r\n|\r|\n/);
const defaultOptions = {

View File

@ -1,36 +0,0 @@
diff --git a/browser.js b/browser.js
index e07f78d17b7b4a2963e4f0062047cc96e6025f9e..a9f266a2644f3f8ebd0f6684b3e11a7519059851 100644
--- a/browser.js
+++ b/browser.js
@@ -3,6 +3,7 @@ const base64 = require('./lib/base64')
const hex = require('./lib/hex')
const utf8 = require('./lib/utf8')
const utf16le = require('./lib/utf16le')
+const Buffer = require('buffer').Buffer
const LE = new Uint8Array(Uint16Array.of(0xff).buffer)[0] === 0xff
diff --git a/index.js b/index.js
index a751d6b4d27c7dd903efbfdc87a98f61044a62b8..8bd32640afdcfbc475168d458c51f8b9162d1656 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+const Buffer = require('buffer').Buffer
+
function isBuffer (value) {
return Buffer.isBuffer(value) || value instanceof Uint8Array
}
diff --git a/package.json b/package.json
index eb0f792709b27e66f26658054781b4099507b5ed..69c4ff39c48b0bdd5f0bc7ebbade517e7c5d76e4 100644
--- a/package.json
+++ b/package.json
@@ -8,9 +8,6 @@
"index.js",
"lib"
],
- "browser": {
- "./index.js": "./browser.js"
- },
"scripts": {
"test": "standard && brittle test/*.mjs"
},

63
rollup.config.ts Normal file
View File

@ -0,0 +1,63 @@
// @ts-nocheck
import * as import0 from "@rollup/plugin-json";
import * as import1 from "@rollup/plugin-node-resolve";
import * as import2 from "@rollup/plugin-commonjs";
import * as import3 from "@rollup/plugin-graphql";
import * as import4 from "@rollup/plugin-image";
import * as import5 from "@rollup/plugin-yaml";
import * as import6 from "rollup-plugin-postcss";
import * as import7 from "rollup-plugin-visualizer";
import * as import8 from "@rollup/plugin-wasm";
import * as import9 from "@rollup/plugin-alias";
import * as import10 from "@rollup/plugin-inject";
export default {
input: "build/index.js",
output: [
{
file: "lib/index.js",
format: "cjs",
sourcemap: false,
inlineDynamicImports: true,
},
],
plugins: [
import0.default(...([] as const)),
import9.default({
entries: [
{
find: "net",
replacement: "./build/net.js",
},
{
find: "tls",
replacement: "./build/net.js",
},
],
}),
import1.default(
...([
{
browser: true,
preferBuiltins: false,
dedupe: [
"@lumeweb/libkernel",
"@lumeweb/libweb",
"@lumeweb/libportal",
],
},
] as const),
),
import2.default(
...([{ extensions: [".js", ".jsx", ".ts", ".tsx"] }] as const),
),
import10.default({
Buffer: ["buffer", "Buffer"],
}),
import3.default(...([] as const)),
import4.default(...([] as const)),
import5.default(...([] as const)),
import6.default(...([{ inject: { insertAt: "top" } }] as const)),
import7.visualizer(...([] as const)),
import8.default(...([{ targetEnv: "auto-inline" }] as const)),
],
};