Coder Social home page Coder Social logo

Comments (2)

Stabzs avatar Stabzs commented on May 19, 2024

A few notes first.

I highly recommend always installing as a node module directly via npm install. It seemed as if you weren't and that could create folder hierarchy issues within the package itself if you copy them incorrectly.

Second, I'm by no means a SystemJS expert so I'm continuously learning more about the package manager myself. The demo is set up with what I knew would work but of course I'm happy to expand it to additional examples to support other situations.

The main differences between your setup with or without the map in comparison to my systemjs demo is that you have declared a package. Once you declare a package, you are essentially declaring another root path which is placing the mapped angular2-toaster node module outside of the expected path. You could fix this by moving up a directory for your module inclusion when mapping:

System.config({
    defaultJSExtensions: true,
    packages: {
        app: {
            format: "register",
            defaultExtension: "js"
        }
    },
    map: {
        'angular2-toaster': '../node_modules/angular2-toaster'
    }
});
System.import('app/main')
              .then(null, console.error.bind(console));

In addition, note the defaultJSExtensions: true option. My build/app points to the folder physically located at build/app.js. the default extension ensured it was properly loaded via the import statement. It may be that this is all you need to get it working since it looks like your request IS to the node_modules folder which leads me to think that your app/main.js file actually lives at the root level, not in the logical app folder.

Finally, all of this assumes that when you include the module and build it (assuming you are using typescript although the relative pathing should be the same for es5/es6), you import your module via the full package declaration: angular2-toaster/angular2-toaster.

from angular2-toaster.

Stabzs avatar Stabzs commented on May 19, 2024

Please see the new, additional demo that I added. The package needs to be mapped AND make sure that you are setting your tsconfig.json build option to system, not commonjs as I was in the original systemjs demo (which still shows how you can manually map commonjs builds via systemjs).

from angular2-toaster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.