fix usage as a commonjs module - #41
Conversation
| }; No newline at end of file | ||
| }; | ||
|
|
||
| require('./lawnchairHtml5FileSystem')(Lawnchair) |
There was a problem hiding this comment.
Instead of using concat, these are loaded via require now so browserify will pick them up.
| crypto: { | ||
| src:[ | ||
| "libs/cryptojs/cryptojs-core.js", | ||
| "libs/cryptojs/cryptojs-enc-base64.js", |
There was a problem hiding this comment.
Most of these were referenced but no longer exist.
| } | ||
| }, | ||
| concat: { | ||
| lawnchair: { |
There was a problem hiding this comment.
This is no longer required thanks to browserify.
There was a problem hiding this comment.
Yeah. This is just leftover from js-sdk. Sadly we need to still bundle lawnchair as source code weren't released for the last couple years and we made some fixes directly upstream to maintain it :)
| @@ -1,105 +1,107 @@ | |||
| Lawnchair.adapter('memory', (function(){ | |||
| module.exports = function (Lawnchair) { | |||
There was a problem hiding this comment.
Formatting got a little wild here. Should we run add standard and use standard --fix or similar to keep things consistent? Maybe an .editorconfig too?
There was a problem hiding this comment.
yeah, or we could move them out into its own module. It shouldn't be in this repo I think.
There was a problem hiding this comment.
I think these should reside in require('lawnchair').memoryAdapter.
I'm not sure where the code for these adapters come from originally, since I couldn't find them standalone on npm or on the original repository for lawnchair...
For styling I think we might be a litle closer to semi-standard than standard, just because semicolons are a hot topic. We have a recommended set of styles for our own code somewhere but I couldn't find it right now, going to look further.
EDIT: so it seems the code for most of these adapters is already inside the original repo, just not exposed by the module as commonjs.
There was a problem hiding this comment.
I'm not sure where the code for these adapters come from originally, since I couldn't find them standalone on npm or on the original repository for lawnchair...
They were renamed, removed etc. long time ago.
We using some really old ones. Here is tag that has some of them:
https://github.com/brianleroux/lawnchair/tree/0.6.4/src/adapters
|
Fix confirmed in ng4 Ionic project that uses this module. |
wei-lee
left a comment
There was a problem hiding this comment.
I think for now this is ok. But in the long term, I suggest we move Lawnchair to its own repo, or get rid of it completely.
|
@evanshortiss Thank you so much for starting and providing solution for this important issue. We talked about this issue a lot with @paolobueno BackgroundI'm going to provide some background to explain why we have some external source code in our module. We put lawnchair in our code because original library weren't published for years: Every time browser api changes we making fix in upstream and backport changes in lib folder to make it compatible. For example: Lawnchair doesn't support common.js modules - extensions are just mounted to global var. Concat were used as hack and were causing issues from the beginning. Suggested fixIn my opinion the best course of the action will be to install Lawnchair as dependency. We have two options:
If you guys can +1 this idea this may definitely help.
Current fixThis fix may be the first step to extract Lawnchair out of the sync module. However I do not understand why we committing both source and generated code. We can make assumption that this is library and remove source code as we no longer have ability to concatenate that. |
|
yeah, I think the generated file can be removed now. It's not required anymore. |
|
Actually the author has shown himself willing to merge changes and do a release. I'd PR'd from a personal fork but we could definitely have one in the feedhenry org to move forward faster if we wish to. The minimal fix in brianleroux/lawnchair#233 is still not enough, it's missing practically what @evanshortiss is doing here, making the adapters commonjs modules instead of them expecting to be run on top of |
|
Agreed @wtrocki. If it is published to npm that'd be great and solve our headache here so long as what @paolobueno says is also addressed 👍 Have added +1
I tried to help get it published a long time ago actually! So if it doesn't see activity soon then maybe you're right, we could publish it under |
|
As this may cause some problems in automation etc. I have done prerelease to test it in together with fh-js-sdk and other projects:
@evanshortiss We kinda need consensus here. I think that we may integrate this fix and then look towards using our own version of lawnchair. Do you think we should close this PR and go directly to our version? @david-martin - What's your take on this? |
|
@evanshortiss - I can confirm that this fixes problem with browserify. |
|
@wtrocki I'm happy with either approach really. I suppose the upside of merging this is that it fixes the module temporarily until we can look into using our own version. |
| @@ -0,0 +1,1354 @@ | |||
| /** | |||
|
@evanshortiss - Let's merge it then. Just one small thing to clear that out. |
Work that should address #40. Need to test in my project, but the example is still working after this change.