Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
fix: resolve ERR_PACKAGE_PATH_NOT_EXPORTED in electron
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Sep 8, 2022
1 parent ec5ed97 commit 6fb3077
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .aegir.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path')
const signaller = require('libp2p-webrtc-star-signalling-server')

/** @type {import('aegir').Options["build"]["config"]} */
/** @type {import('esbuild').BuildOptions} */
const esbuild = {
inject: [path.join(__dirname, 'scripts/node-globals.js')],
plugins: [
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:
type:
- electron-main
- electron-renderer
moduleType:
- cjs
- esm
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand All @@ -130,7 +133,7 @@ jobs:
./scripts/custom-runtime.sh
- uses: GabrielBB/xvfb-action@v1
with:
run: npm run test -- -t ${{ matrix.type }} --bail -f dist/cjs/node-test/*js
run: npm run test -- -t ${{ matrix.type }} --bail -f dist/${{matrix.moduleType}}/node-test/*js

release:
needs: [test-node, test-browser, test-electron]
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@
"devDependencies": {
"go-ipfs": "^0.12.2",
"ipfs": "^0.61.0",
"ipfs-http-client": "^55.0.0"
"ipfs-http-client": "^55.0.0",
"ipfsd-ctl-wrapper": "file:test/packages/ipfsd-ctl-wrapper"
},
"browser": {
"go-ipfs": false,
Expand Down
1 change: 1 addition & 0 deletions test/packages/ipfsd-ctl-wrapper/cjs-index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = async () => await import('ipfsd-ctl')
5 changes: 5 additions & 0 deletions test/packages/ipfsd-ctl-wrapper/esm-index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as ipfsdCtl from 'ipfsd-ctl'

// export default ipfsdCtl
// export const createFactory = ipfsdCtl.createFactory
export default async () => ipfsdCtl
10 changes: 10 additions & 0 deletions test/packages/ipfsd-ctl-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "ipfsd-ctl-wrapper",
"exports": {
".": {
"import": "./esm-index.mjs",
"require": "./cjs-index.cjs",
"default": "./cjs-index.cjs"
}
}
}
16 changes: 8 additions & 8 deletions test/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('pubsub', function () {
const data = uint8ArrayFromString('hello world')
const topic = 'pubsub-ascii'

const subscriber = () => new Promise((resolve) => {
const subscriber = () => /** @type {Promise<void>} */(new Promise((resolve) => {
daemon2.api.pubsub.subscribe(topic, (msg) => {
expect(uint8ArrayEquals(data, msg.data)).to.be.true()
expect(msg).to.have.property('seqno')
Expand All @@ -85,7 +85,7 @@ describe('pubsub', function () {
expect(msg).to.have.property('from', daemon1.peer.id)
resolve()
})
})
}))

const publisher = async () => {
await waitForTopicPeer(topic, daemon2.peer, daemon1)
Expand All @@ -102,7 +102,7 @@ describe('pubsub', function () {
const data = uint8ArrayFromString('你好世界 zażółć gęślą jaźń')
const topic = 'pubsub-non-ascii'

const subscriber = () => new Promise((resolve) => {
const subscriber = () => /** @type {Promise<void>} */(new Promise((resolve) => {
daemon2.api.pubsub.subscribe(topic, (msg) => {
expect(uint8ArrayEquals(data, msg.data)).to.be.true()
expect(msg).to.have.property('seqno')
Expand All @@ -111,7 +111,7 @@ describe('pubsub', function () {
expect(msg).to.have.property('from', daemon1.peer.id)
resolve()
})
})
}))

const publisher = async () => {
await waitForTopicPeer(topic, daemon2.peer, daemon1)
Expand All @@ -128,7 +128,7 @@ describe('pubsub', function () {
const data = uint8ArrayFromString('a36161636179656162830103056164a16466666666f400010203040506070809', 'base16')
const topic = 'pubsub-binary'

const subscriber = () => new Promise((resolve) => {
const subscriber = () => /** @type {Promise<void>} */(new Promise((resolve) => {
daemon2.api.pubsub.subscribe(topic, (msg) => {
expect(uint8ArrayEquals(data, msg.data)).to.be.true()
expect(msg).to.have.property('seqno')
Expand All @@ -137,7 +137,7 @@ describe('pubsub', function () {
expect(msg).to.have.property('from', daemon1.peer.id)
resolve()
})
})
}))

const publisher = async () => {
await waitForTopicPeer(topic, daemon2.peer, daemon1)
Expand All @@ -154,7 +154,7 @@ describe('pubsub', function () {
const data = uint8ArrayFromString('你好世界\nzażółć\r\ngęślą\njaźń')
const topic = 'pubsub\n你好世界\r\njaźń'

const subscriber = () => new Promise((resolve) => {
const subscriber = () => /** @type {Promise<void>} */(new Promise((resolve) => {
daemon2.api.pubsub.subscribe(topic, (msg) => {
expect(uint8ArrayEquals(data, msg.data)).to.be.true()
expect(msg).to.have.property('seqno')
Expand All @@ -163,7 +163,7 @@ describe('pubsub', function () {
expect(msg).to.have.property('from', daemon1.peer.id)
resolve()
})
})
}))

const publisher = async () => {
await waitForTopicPeer(topic, daemon2.peer, daemon1)
Expand Down
3 changes: 2 additions & 1 deletion test/utils/daemon-factory.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

import { createFactory } from 'ipfsd-ctl'
import isNode from 'detect-node'
import ipfsdWrapper from 'ipfsd-ctl-wrapper'

export async function daemonFactory () {
let ipfsHttpModule
let ipfsModule
const { createFactory } = await ipfsdWrapper()

try {
ipfsHttpModule = await import(process.env.IPFS_JS_HTTP_MODULE)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"src",
"test"
]
}
}

0 comments on commit 6fb3077

Please sign in to comment.