Search code examples
requirejsamdsystemjs

Can system.js replace require.js


I'm using requirejs in a large project. This project will soon be upgraded to angular2.

Angular2 uses system.js, so I'm thinking of switching to system.js too. Should I be able to remove the reference to the requirejs library and include system.js instead and expect it to work, or is there something I don't understand here?

I tried by just removing the require.js file and adding the system.js file instead, but I get error messages saying define is not defined. Can you help? Will I need require.js in addition to system.js?


Solution

  • I just switched to system.js too. You need to replace your require.js with system.js and add simple script tag. So it should look like this:

    <script src="~/lib/system.js/dist/system.js" type="text/javascript"></script>
    <script>  
        // set our baseURL reference path
        System.config({
            baseURL: '/app'
        });
        System.import('startup.js');
    </script>