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

Yet Another Switch to CommonJS #456

Merged
merged 64 commits into from
Jan 10, 2017
Merged

Yet Another Switch to CommonJS #456

merged 64 commits into from
Jan 10, 2017

Conversation

davidlehn
Copy link
Member

@davidlehn davidlehn commented Dec 16, 2016

This is another attempt at a CommonJS switch. It's similar to #357 but attempts to change the code structure less and adds testings updates.

  • Minimal churn from the old style. Mostly a removal of boilerplate and adapting to CommonJS style. This was to avoid changing everything at once. Things can be further refactored once the first major switch happens. Have requires() build up the forge object may be a questionable style but lets address that later.
  • Top-level forge object no longer can be called with new options. There is now a single forge.options object. For now only including the renamed disableNativeCode as usePureJavaScript.
  • Browser bundles built with webpack. Fairly easy to adapt to just build what you want. It could build bundles for every file, but that makes little sense. Better to let people build what they need which now works (I hope).
  • Browserify testing. It worked at some point and has some support in the package.json files but hasn't been tested recently.
  • Testing: Node.js
  • Testing: In a browser manually via a webpack build of all tests with forge
  • Testing: PhantomJS, Chrome, Firefox, and Safari via Karma (webpack version)
  • Testing: PhantomJS, Chrome, Firefox, and Safari via Karma (browserify version)
  • Testing: Travis-CI passing Node.js and PhantomJS tests
  • Docs updated
  • Some style and misc cleanups
  • Bower support. I'm totally against adding the built files to the main repo. We may need to have a secondary repo just to store built files.
    • Plan is a new forge-dist repo for built bower/bundle support. 0.6.x code will be imported so old checkouts should continue to work the same. And new 0.7.x checkouts will be totally different but should work for many uses. Custom cases will require a new workflow of building your own bundle.
  • Update files in ./tests/
  • Add docs on various tools and methods to create custom bundles
  • Move testing files from ./nodejs to root dir
  • prime.worker.js + jsbn.js need to work in browsers without CommonJS support.
  • Move Python test server functionality to Node.js.
  • Check/update WebSockets tests.
  • Check/update WebSocket+WebID tests. [expired test cert, missing webid server] (did some work, not updating futher at this time)
  • Remove as much old build system cruft as possible.
  • Add some (not too slow) nodejs and web tests with forge.options.usePureJavaScript===true.
  • webpack vs node/browserify test count.
  • pkcs7 test: FIXME for date > 2050 [tests added and skipped in PhantomJS due to Date bug]
  • Add a CHANGELOG
  • Add security considerations section to README
  • .editorconfig
  • Check npm pack.
  • Rename 0.7.x branch to 0.8.x.

As this is a rather major change it needs testing and feedback before hitting master. At a minimum the bower issue needs solving. Please test and leave comments, thanks!

@davidlehn davidlehn force-pushed the cjs branch 2 times, most recently from cfbc40f to 4c9a0b6 Compare December 21, 2016 02:45
@davidlehn
Copy link
Member Author

Updates:

  • Lots of test refactoring. Moved everything around and updated (mostly) everything to (mostly) work.
  • Updated Node.js test server to run more tests. Has http, https, and basic flash policy server support. Almost free of python deps with possible exception of adding ssl session support to node test server.
  • Misc things all over.

@davidlehn
Copy link
Member Author

Updates:

  • Lots of build system cleanup. The old cruft is gone.
  • Python test server gone and using Node.js now.
  • Flash support cleaned up, builds work, and tests work.
  • WebSocket support cleaned up and tests work.
  • Browserify testing added.

- More common that js/.
- Minimally invasive first pass conversion to CommonJS usage.
- Change `forge.js` to be top-level container. Preserve code style of
  files adding properties to the `forge` object.
- Add `index.js` as main node file. `require` other files as `forge.js`
  did before.
- Remove boilerplate from all files.
- Change dependencies into `require` calls.
- Minimally invasive first pass conversion to CommonJS usage.
- Keep IIFEs to avoid re-indent of all test code.
- Keep CAPS var style to avoid large diff.
- Remove boilerplate from all files.
- Change dependencies into `require` calls.
- Needed for tools like browserify due to early return call.
- Remove abilty to create a new forge container by calling the top-level
  container with new options. Doing this correctly would add too much
  implementation complexity compared to its usefulness.
- Move global options to the forge.options object.
- Change disableNativeCode option to usePureJavaScript.
Use common Node.js checking logic.
- Add jshint dependency.
- Allow ES2015 for jshint.
- Update dependencies: remove almond and requirejs, add webpack.
- Add Browserify support to package.json.
- Add `npm run build` command.
- Build both un-minimized and minimized with sourcemap bundles.
- Output built files to dist/.
- Update README.
- Update READMEs.
- Add Karma support.
- Karma plugins: webpack, mocha, phantomjs, chrome, firefox.
- Remove requirejs test method in favor of webpack builds.
- Update dependencies.
- Simplify manual browser test files.
- Remove "browser" test in favor of Karma.
- Move files:
  - Examples to examples/.
  - Tests to tests/.
  - Test server to tests/.
  - Core unit tests to tests/unit/.
  - Legacy browser tests to tests/legacy/.
  - Benchmarks to tests/benchmarks/.
  - WebSockets related to tests/websockets/.
  - Issue related to tests/issues/.
  - Support files to root.
  - Test deps added to main package.json.
- Update paths everywhere.
- Built bundles:
  - Support building multiple configurations.
  - dist/forge.js: core forge.
  - dist/forge.all.js: core + extra utils + networking.
- Update lib/form.js, lib/xhr.js to CommonJS.
- Update READMEs.
- Update test server with appropriate files.
- Add primary test index.
- Update legacy index and files for new layout.
- Update tests to use single forge bundles.
- Remove test trailing whitespace.
- Turn off legacy test scrolling due to performance.
- Move ToC closer to top.
- Add more to ToC.
- Update build and test sections.
- Misc changes and fixes.
- Move to DRY code.
- Use short and easy to visually scan functions: _I_(), _IN().
- Saves many bytes of duplicated strings in output bundles.
- Remove custom ssl module and build support.
- Remove Python test server (replaced by Node.js server).
- Update README.

### Removed

- Can no longer call `forge({...})` to create new instances.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include a **BREAKING** prefix.

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.

3 participants