Sunday, October 9, 2016

Migrating to Ionic 2 RC 0 - CommonJS files

After migrating my app to Ionic 2 RC 0, I was able to typescript-compile my app, but the bundling failed with
bundle dev failed:  Module .../node_modules/log4javascript/log4javascript.js does not export getRootLogger 
Finally, after some googling, I found out, that I had to define the so-called custom named exports of log4javascript by myself:
  1. Copy rollup.config.js from node_modules/@ionic/app-scripts/config into my own config directory.
  2. Change my package.json according to the documentation:
    "config": {
      "ionic_rollup": "./config/rollup.config.js"
    },
    
  3. Add configuration for commonjs plugin in rollup.config.js:
    plugins: [
      commonjs({
        include: [
          'node_modules/log4javascript/**',
        ],
        namedExports: {
          'node_modules/log4javascript/log4javascript.js': [
            'Appender', 'BrowserConsoleAppender', 'getLogger', 'getRootLogger', 'Level', 'LoggingEvent', 'logLog', 'PatternLayout'
          ]
        }
      }),
      ...
    ]
    
As you can see, I had to define every single thing I used from log4javascript. Not beautiful, but it works.

8 comments:

  1. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
    Android App Development Company

    ReplyDelete

  2. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    PHP training in chennai

    ReplyDelete
  3. I just want to say that all the information you have given here is awesome...great and nice blog thanks sharing..Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Web Design Development Company
    Web design Company in Chennai
    Web development Company in Chennai

    ReplyDelete
  4. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  5. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    iOS App Development Company

    ReplyDelete
  6. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text

    ReplyDelete
  7. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  8. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Texting API
    Sms API
    Sms marketing

    ReplyDelete