Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use js-ipfs-unixfs in a browser environment #6

Closed
wants to merge 5 commits into from
Closed

Use js-ipfs-unixfs in a browser environment #6

wants to merge 5 commits into from

Conversation

bgrieder
Copy link

@bgrieder bgrieder commented Apr 3, 2016

This PR is for using this library in a browser environment
See #5 which is a pre-requisite for ipfs/js-ipfs#104

However, I could not get the browser tests going and I am confused by the way dignified.js works

@dignifiedquire Could you please shed some light on how to do this ?

Here is what I have done:

  • add webpack 2.1.0-beta.4 as a dev dependency
  • split the tests in two
    • unix-format.spec.js : tests run on both node and the browser
    • unix-format-node.spec.js: tests to run on node only
      • add test/browser.js which selects tests files into the webpack context not ending with -node.spec.js

Running ./node_modules/.bin/dignified-test browser results in

[09:39:57] Starting 'test:browser'...
[09:39:57] Starting 'karma'...

03 04 2016 09:40:02.638:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
03 04 2016 09:40:02.644:INFO [launcher]: Starting browser Chrome
03 04 2016 09:40:03.439:INFO [Chrome 49.0.2623 (Mac OS X 10.11.4)]: Connected on socket     /#O2nGMlJ9RMBUef9AAAAA with id 386536
Chrome 49.0.2623 (Mac OS X 10.11.4) ERROR
  Script error.
Chrome 49.0.2623 (Mac OS X 10.11.4) ERROR
  Script error.
03 04 2016 09:40:03.852:INFO [launcher]: Starting browser PhantomJS
03 04 2016 09:40:04.326:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#BASMdfjJyRgBLp1CAAAB with id 65531913
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  Error: Cannot find module "."
  at undefined:8
03 04 2016 09:40:04.425:WARN [karma]: Test suite was empty.

  0 passing (6s)

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  Error: Cannot find module "."
  at undefined:8
03 04 2016 09:40:04.436:WARN [karma]: Test suite was empty.

  0 passing (6s)

[09:40:04] Finished 'karma' after 6.57 s
[09:40:04] Finished 'test:browser' after 6.57 s
[09:40:04] 'karma' errored after 6.57 s
[09:40:04] Error: task completion callback called too many times
    at finish (/Users/bgrieder/projects/js-ipfs-unixfs/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/Users/bgrieder/projects/js-ipfs-unixfs/node_modules/orchestrator/lib/runTask.js:29:3)
    at /Users/bgrieder/projects/js-ipfs-unixfs/node_modules/dignified.js/tasks/test/browser.js:16:9
    at removeAllListeners (/Users/bgrieder/projects/js-ipfs-unixfs/node_modules/karma/lib/server.js:336:7)
    at /Users/bgrieder/projects/js-ipfs-unixfs/node_modules/karma/lib/server.js:347:9
    at Server.<anonymous> (net.js:1467:9)
    at Server.g (events.js:273:16)
    at emitNone (events.js:85:20)
    at Server.emit (events.js:179:7)
    at emitCloseNT (net.js:1514:8)
    at nextTickCallbackWith1Arg (node.js:464:9)
    at process._tickCallback (node.js:386:17)

@bgrieder bgrieder changed the title Use fo js-ipfs-unixfs in a browser environment Use js-ipfs-unixfs in a browser environment Apr 3, 2016
@daviddias daviddias force-pushed the master branch 2 times, most recently from a86560a to 9c342d1 Compare April 3, 2016 16:59
@daviddias
Copy link
Member

You won't need to add webpack as a dep of this repo. You can learn more about the 'dignified' pipeline here https://github.com/ipfs/community/blob/update/js-project-guidelines/js-project-guidelines.md . We are still in the process of updating our repos to follow this process and polishing last minute details. Apologies for it not being crystal clear yet.

I've updated master README and republished this repo using dignified.js. Tests are passing in Node.js and the browser, could you confirm from your side?

@bgrieder bgrieder closed this Apr 4, 2016
@bgrieder
Copy link
Author

bgrieder commented Apr 4, 2016

@diasdavid Yes they are. I see there is a transform-loader changing all static fs.readFileSync to hardcoded Buffers
I am impressed with dignified.js.
Now this also means that all downstream repos need to be converted to dignified so that the same transform applies when generating browser code.

achingbrain pushed a commit that referenced this pull request Feb 19, 2020
achingbrain added a commit that referenced this pull request Feb 19, 2020
achingbrain added a commit that referenced this pull request Feb 19, 2020
chore: replace last few pull.* invocations with *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants