Repository: onflow/fcl-js
Pull request #1176 (2022-05-11 21:50:53)

PKG -- [util-node-http-modules] Fix microbundler

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: dd6f694c43915e6b5eb28cdc062c0e852413c101

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/onflow/fcl-js/new/jribbink/util-node-http-modules?filename=.changeset/sweet-teachers-guess.md&value=---%0A%22%40onflow%2Futil-node-http-modules%22%3A%20patch%0A---%0A%0APKG%20--%20%5Butil-node-http-modules%5D%20Fix%20microbundler%0A)


chasefleming: Cool!

Patch:
diff --git a/.changeset/big-tips-itch.md b/.changeset/big-tips-itch.md
new file mode 100644
index 00000000..0a1f8cb1
--- /dev/null
+++ b/.changeset/big-tips-itch.md
@@ -0,0 +1,5 @@
+---
+"@onflow/util-node-http-modules": minor
+---
+
+Fixed issue where microbundler was not building util-node-http-modules package
diff --git a/package-lock.json b/package-lock.json
index fd4a2e09..db2d03c6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6995,6 +6995,11 @@
       "dev": true,
       "license": "MIT"
     },
+    "node_modules/http": {
+      "version": "0.0.1-security",
+      "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
+      "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
+    },
     "node_modules/http-proxy-agent": {
       "version": "4.0.1",
       "dev": true,
@@ -7022,6 +7027,11 @@
         "npm": ">=1.3.7"
       }
     },
+    "node_modules/https": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
+      "integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q="
+    },
     "node_modules/https-browserify": {
       "version": "1.0.0",
       "dev": true,
@@ -31142,6 +31152,10 @@
       "name": "@onflow/util-node-http-modules",
       "version": "1.0.0-alpha.0",
       "license": "Apache-2.0",
+      "dependencies": {
+        "http": "^0.0.1-security",
+        "https": "^1.0.0"
+      },
       "devDependencies": {
         "jest": "^27.0.6",
         "jest-esm-transformer": "1.0.0",
@@ -48114,6 +48128,8 @@
     "@onflow/util-node-http-modules": {
       "version": "file:packages/util-node-http-modules",
       "requires": {
+        "http": "^0.0.1-security",
+        "https": "*",
         "jest": "^27.0.6",
         "jest-esm-transformer": "1.0.0",
         "microbundle": "^0.13.3"
@@ -54442,6 +54458,11 @@
       "version": "2.0.2",
       "dev": true
     },
+    "http": {
+      "version": "0.0.1-security",
+      "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
+      "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
+    },
     "http-proxy-agent": {
       "version": "4.0.1",
       "dev": true,
@@ -54460,6 +54481,11 @@
         "sshpk": "^1.7.0"
       }
     },
+    "https": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
+      "integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q="
+    },
     "https-browserify": {
       "version": "1.0.0",
       "dev": true
diff --git a/packages/util-node-http-modules/package.json b/packages/util-node-http-modules/package.json
index aebbd443..54b19414 100644
--- a/packages/util-node-http-modules/package.json
+++ b/packages/util-node-http-modules/package.json
@@ -22,21 +22,16 @@
         "jest-esm-transformer": "1.0.0",
         "microbundle": "^0.13.3"
     },
-    "main": "./src/util-node-http-modules.noop.js",
-    "exports": {
-        "node": {
-            "import": "./src/util-node-http-modules.module.js",
-            "require": "./src/util-node-http-modules.cjs.js"
-        },
-        "default": "./src/util-node-http-modules.noop.js"
-    },
+    "source": "src/util-node-http-modules.js",
+    "main": "dist/util-node-http-modules.js",
+    "module": "dist/util-node-http-modules.module.js",
+    "unpkg": "dist/util-node-http-modules.umd.js",
     "scripts": {
         "alpha": "npm publish --tag alpha",
         "prepublishOnly": "npm test && npm run build",
         "test": "jest",
-        "build": "microbundle --no-compress",
+        "build": "microbundle --no-compress --external http,https",
         "test:watch": "jest --watch",
-        "start": "microbundle watch --no-compress"
-    },
-    "dependencies": {}
+        "start": "microbundle watch --no-compress --external http,https"
+    }
 }
diff --git a/packages/util-node-http-modules/src/util-node-http-modules.cjs.js b/packages/util-node-http-modules/src/util-node-http-modules.cjs.js
deleted file mode 100644
index c884b8e6..00000000
--- a/packages/util-node-http-modules/src/util-node-http-modules.cjs.js
+++ /dev/null
@@ -1,17 +0,0 @@
-module.exports = {
-  async getNodeHttpModules() {
-    let nodeHttpsTransport
-    try {
-      nodeHttpsTransport = require("https")
-    } catch (e) {}
-    let nodeHttpTransport
-    try {
-      nodeHttpTransport = require("http")
-    } catch (e) {}
-
-    return {
-      nodeHttpsTransport,
-      nodeHttpTransport
-    }
-  } 
-}
diff --git a/packages/util-node-http-modules/src/util-node-http-modules.module.js b/packages/util-node-http-modules/src/util-node-http-modules.js
similarity index 100%
rename from packages/util-node-http-modules/src/util-node-http-modules.module.js
rename to packages/util-node-http-modules/src/util-node-http-modules.js
diff --git a/packages/util-node-http-modules/src/util-node-http-modules.noop.js b/packages/util-node-http-modules/src/util-node-http-modules.noop.js
deleted file mode 100644
index f338092f..00000000
--- a/packages/util-node-http-modules/src/util-node-http-modules.noop.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export async function getNodeHttpModules() {
-  return {
-    nodeHttpsTransport: undefined,
-    nodeHttpTransport: undefined,
-  }
-}
-  
\ No newline at end of file


Test patch:
diff --git a/packages/util-node-http-modules/src/util-node-http-modules.test.js b/packages/util-node-http-modules/src/util-node-http-modules.test.js
index 7b3b8a2f..b54fbd2d 100644
--- a/packages/util-node-http-modules/src/util-node-http-modules.test.js
+++ b/packages/util-node-http-modules/src/util-node-http-modules.test.js
@@ -1,4 +1,6 @@
-test("placeholder", () => {
-    expect(1).toBe(1)
-})
-  
\ No newline at end of file
+import { getNodeHttpModules } from './util-node-http-modules'
+
+test("HTTP Transports exist", async () => {
+    const { nodeHttpsTransport, nodeHttpTransport } = await getNodeHttpModules()
+    expect(nodeHttpTransport | nodeHttpsTransport).toBeDefined()
+})
\ No newline at end of file