-
Notifications
You must be signed in to change notification settings - Fork 304
Using CommonJS modules with rollup #16
Comments
Hi @shlomiassaf, We're not sure what you mean. We do support Please let me know if this fixes your issue. I'll re-open if needed. Thanks, |
@danbucholtz Why did you close the issue? is this a common behaviour for people contributing to your project? You didn't solve it... Now, before you run and close try to look into the issue. I kindly ask you to try and integrate angularfire2 or lodash. I'm trying to save you a lot of time and complaints later on, I'v spent a lot of hours on this beta, this is not how you should treat people who try to help. This is insulting Jus to clarify, the reason I react like that is that the same error was closed in #3 without a solution... |
Here's another issue for you: In watch mode when using Save something and the next update will error since using cache for rollup causes an issue. I'v managed to workaround the angularfire issue and now this cache thing you introduced broke it... I know sometime people pollute the issues but this is not the case, anyone who could use the beta.12 without docs should be taken seriously, its across 4 repos of integration. |
Hi, I am seeing an issue here. I'll look into it. The goal is the user doesn't need to care if a 3rd party lib is commonjs or es2015 modules. Thanks, |
I know it's the goal and I also now that you'll get tons of complaints for these 2 libs only... I'm trying to help. |
@shlomiassaf we're looking into it and taking it seriously. This needs to Just Work or it won't be acceptable on our end. Apologies for the confusion. |
@danbucholtz @mlynch This is really a core issue with the rollup bundling process. Now BTW, I had to use |
Hi @shlomiassaf, We are aware of this issue and working on it. I don't have more to share right now but I hope to soon. Thanks, |
Hi @shlomiassaf, I have successfully created a project with moment, lodash, node-uuid, localforage. All commonjs modules. You're right there is an issue here. I've come up with a solution. I'll have more details on it tomorrow. In the meantime, the code changes to app-scripts to facilitate it are here: Thanks, |
@danbucholtz thanks! I couldn't load
I had to use default syntax:
This requires
in Problem is i'm getting a new error now, in runtime...
|
Nice find with the allowSyntheticDefaultImports option. I'll play around with it - this sounds like the secret sauce that we need to make things work the way we want! I'll have an update coming soon. Thanks, |
That option is working great so far! Thanks, |
I made my sample project public. Check it out. https://github.com/driftyco/ionic-third-party-lib-example Thanks, |
@danbucholtz Thanks! great progress. It looks like the bundling issue is solved. The cache issue is still there. The node UUID lib uses the 3rd party
If we disable caching of the rollup bundle by commenting out this line code update works without a problem. So, the problem is that caching somehow does not respect previous configuration. For me this happened when using
|
@danbucholtz, still can't use |
@danbucholtz keep an eye on angular/angularfire#565 |
Hi @danbucholtz, I am facing similar issues over using external libraries like
It seems to me I'm doing something stupid and overlooking something simple.. Could you please help in this regard? |
I'm thinking the sublime plugin you're using likely does not support the latest major version of Typescript (2.0). Give vscode a shot, it is maintained by Microsoft so it works incredibly well with Typescript. Thanks, |
@awe-sim As a rule of thumb I always check console errors when running the complication and only then take the IDE errors seriously. No error in console, no issue. It's hard for IDE plugins to keep up when changes are so often :) |
@danbucholtz .. Thanks for pointing the issue out.. Yes the sublime plugin supported typescript v <2.0.. Using VSCODE now and its working good.. Thanks a lot.. =) |
@shlomiassaf, any leads on what's going on with AngularFire? Sounds like they may use a dependency that rollup can't handle? We may need to make WebPack an option if Rollup can't handle all libs. That would be unfortunate as performance would suffer. Thanks, |
I'm also having a similar issue with moment-timezone. I would love it if you guys reverted to webpack until rollup is more seriously vetted. The collective amount of time the community has wasted battling with this new build system is a rough indictment of the quality of this release. That, coupled with the general confusion on importing styles, iOS build failures with ionic package, et al... is just not consistent with the quality you guys typically ship with :/ Sorry to rant here, as I know it's not the place; it's just be a super frustrating 48 hours trying to migrate my beta11 project to rc0. |
@danbucholtz I think you should have a talk with the firebase guys. I'm not sure the issue is with the rollup build process, and if it is it's unique to the firebase build... Just to recap I will sum up... Rollup can't handle firebase.It should be noted that this happens when firebase is imported from angularfire2 I have not checked what happens if we omit angularfire2 and try to import firebase alone. To workaround for now see this issue comment Rollup watch not working when using
|
@mlynch & @danbucholtz About your note, moving to Webpack instead of Rollup.
There are lot's of other reasons, really so many. the
The angular team is going to release a lot of tools used by the Angular CLI as decoupled webpack plugins (see npm namespace I really thing you should reconsider and move to webpack. BTW: My angular 2 library is using webpack for development and Rollup for UMD bundling so I can deploy an AOT ready library and an ES5 (UMD) library... It's possible to integrate the 2 |
@danbucholtz Thanks for writing a doc on external library usage. With the Ionic 2 beta releases I had also problems with Chart.js ([http://www.chartjs.org/]) and ended up with a quick-and-dirty load in index.html. I could not test it with RC0 until now, because I am still struggling to get PouchDB started, which was fine in the Betas... For now, I will stop with this Ionic 2 project and wait until third party libs are more easily loaded into Ionic 2. |
I have problem with angular-in-memory-web-api: angular/in-memory-web-api#42 |
All, We've posted some docs on the subject. Note: They match a version of http://ionicframework.com/docs/v2/resources/third-party-libs/ Here's an example with AngularFire2. Please let me know how everything goes. I'm going to close this issue for now as we've shipped the documentation. Thanks, |
@danbucholtz i'm seeing you have that example with lodash, however what about lodash modules? Say i'm importing it like this: import { map, reduce } from 'lodash'; Then the freaking cli complains: bundle dev failed: Module /home/carlos/Carlos/OSGroup/startApp/node_modules/lodash/lodash.js does not export map (imported by /home/carlos/Carlos/OSGroup/startApp/src/providers/db.ts)
[12:27:34] Error: Module /home/carlos/Carlos/OSGroup/startApp/node_modules/lodash/lodash.js does not export map (imported by /home/carlos/Carlos/OSGroup/startApp/src/providers/db.ts) This was working with my Webpack setup right before i started transitioning to Rollup. |
Try this: |
@shlomiassaf, you figure out the cache thing? I am trying to come up with a solution for it right now. Thanks, |
@Kobzol Yes i know that can be done, the objective of importing the individual modules was to limit the size of the lodash import, maybe three shaking takes care of it, idk but still this should work. @danbucholtz for the time being i'm going to import the full lodash lib, is there any issue to track about those kind of sub-modules with Rollup or this repo? |
@Luchillo, You're importing the entire If you want everything to just work nicely, In general, if a named export like this The JS community is right on the verge of a massive shift from We just need to get through the next few months to get there. Thanks, |
Ok so Also i don't see the Ok no type definitions, but at least i just had to find->replace the imports in 27 files on my project, i can't begin to imagine how many places would i have to go and change manually without |
Now here start my hell, i had a whole range of libs in my Webpack config, how am i supposed to import this libs or their equivalent in Rollup?:
I also have 1 custom font i need to copy/paste, is that in the assets folder? |
@Luchillo, I don't think your code will have to change much at all. For the most part, anything that was like this:
should become:
If the fonts go into a folder in Thanks, |
Ok that leaves moment, lodash, ng2-charts all green. However intl, web-animations-js were called in a My webpack config used the Lastly i need to define a variable, what i do is to require the package.json, then use the version attribute to set the May i need to copy rollup.config.js and start hacking? |
@Luchillo, Here is the documentation on customizing the build process. So far we only have it populated for http://ionicframework.com/docs/v2/resources/app-scripts/ Thanks, |
@danbucholtz So i started editing my Rollup config, it compiles with only a few warnings about unused vars, however in browser this error pop's in console: Uncaught ReferenceError: IntlPolyfill is not defined Which i've tested and it has an error with my polyfills that i'm trying to import in import './polyfills'; I've tested commenting the imports in that file and error changes depending the lib that is first in the file, if i comment |
@Luchillo, Maybe it is best to create a post on the Ionic forum. We're happy to help but I'm not sure this is the correct medium with all of the other subscribers. I would need to see your code to help further. I don't have the necessary context. Thanks, |
Yes, i already have, however the response time of anyone that can really help in this new issues is close to 2+ weeks, here's the post, it has more context about how am i trying to import, i don't think is that complex to reason about: https://forum.ionicframework.com/t/how-to-rollup-pollyfils/66108 |
Hey folks, I have a couple projects with this setup so I created a post about how to get it working. Not ideal, but until the Firebase team updates their code base it's the best I could do. http://alexmgrant.github.io/ionic/firebase/rc0/lodash/2016/10/06/ionic-rc0-&-firebase.html |
@danbucholtz I'm having issues with ImmutableJS, getting a |
I was able to import and use immutable. If you want to use See here for an example, and see our docs on third party libs here. See the bundle section here. Thanks, |
I'm having trouble using d3 and d3-request specifically. According to Mike Bostock the bundle process "is not importing the code from the ES2015 source, per the module (and jsnext:main) entry point defined in the package.json. Instead it appears to be pulling from the generated UMD bundle" If anyone could help me resolve this, there's a 100 bounty on my stackoverflow question which I'm almost certain is related to this issue. http://stackoverflow.com/questions/39909200/d3-4-0-import-statement-gives-moduleexports-wrapper |
d3 has a strange default export, so I had to use the full module import syntax. It is important to note that in this case, d3 is a "wrapper" object that follows the es2015 standard. It is an object containing reference to all of the exports.
The log statement should reveal what fields it has and the docs should reveal how to use them. We are definitely importing the code from Thanks, |
Hello all, Just as a follow up, we have a PR open right now adding Webpack support. Webpack 2 beta has come a long way and the start-up time gap is not nearly as long as it once was. Hopefully this will be released sometime next week. Thanks, |
@danbucholtz Man i'm glad to hear that, i'll be the first (or at least i'll try) to implement it when the PR get's merged. |
@danbucholtz I checked all the links and also your mega test. I am trying to use https://github.com/videogular/videogular2 The instructions to install and use it are here: It already runs in Angular 2 using TypeScript. Thanks |
I have same issues. Ionic bundles succesfully in case of 'out of the box' but customizing is painful. Rollup still has lot of issues with external libraries. I cannot understand why it was choosen. I tried to use webpack with Ionic2RC1 in my project.
I even tried to build Ionic2 from sources but I've met runtime error Few words about performance.Webpack has code-splitting and CommonChuncks plugin which significaly improve development performance. Few words about gulpIt is not a bundling tool now. It is tusk runner, for every job you lazy to do manually, from bundling application with webpack or any other bundler to signing android release APK and opening Xcode. |
@dan: Thanks for adding webpack support. I am eagerly waiting for this support :-) ` Finished in 0.7 secs / 0 secs I assume this will be addressed with your webpack support to moment-timezone? Thanks, |
We have entered a beta testing phase with Webpack. Please see this post if interested in testing. Specifically, we're looking for library incompatibility and additional We are only using Webpack as a javascript bundler - not as the development server, other asset bundler, etc. We intend to support Rollup going forward as well. Thanks, |
@adamdbradley I think you closed #3 in a rush.
angularfire2 and firebase are something you can't ignore when thinking ionic...
It's also not specific to them, it's a problem when using rollup, I think the rollup process needs to handle commonJS directories transparently.
I now have another, similar error with
lodash
When I:
I get:
Again, there is a workaround but ionic developer shouldn't get hard time on simple tasks:
This is not perfect, there is a TS error:
BTW, rollup does a wired thing when doing:
assign
will be the module, with adefault
property which is the assign function...I know you considered #3 as someone else's problem but
app-scripts
is part of the ionic CLI and if the integration is not smooth you'll get ton's of complaints.If you integrate
rollup
you need it to be transparent.The text was updated successfully, but these errors were encountered: