Gbuomprisco / ng2-material-dropdown

Angular 2 Material-like Dropdown Component
MIT License
37 stars 54 forks source link

Can you tell me how to configure your module in systemjs.config.js file? #23

Open Muthu2020 opened 7 years ago

jasonburrows commented 7 years ago

Yes this!
If I add this to my packages section:

      'ng2-material-dropdown' : {
        main: './index.js',
        defaultExtension: 'js'
      }

I get http://localhost:3000/node_modules/ng2-material-dropdown/index.js 404 (Not Found)

...but if I add the dist folder in the path:

      'ng2-material-dropdown' : {
        main: './dist/index.js',
        defaultExtension: 'js'
      }

I get http://localhost:3000/node_modules/ng2-material-dropdown/dist/dist/src/index.js 404 (Not Found)

(notice the double 'dist'). I've tried many other combinations and haven't found anything that works.

Gbuomprisco commented 7 years ago

Hi!

Can you try like this:

{
   main: 'dist/ng2-dropdown.bundle.js',
  defaultExtension: 'js',
  format: 'cjs'
}

Please reopen if still not working. I will add this to the documentation

jasonburrows commented 7 years ago

Thanks @Gbuomprisco - did this but now I get a new error:

Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-material-dropdown/dist/style.scss.js(…)

(I can't actually reopen this issue. Maybe this is a new issue anyway...)

Gbuomprisco commented 7 years ago

Hi @jasonburrows,

In my experience this happens as systemjs tries to load with .js extension also other files. If you add this file to the config with defaultJSExtension: false, it should work.

jasonburrows commented 7 years ago

@Gbuomprisco - thanks, but no I get the same error. I have tried also removing defaultExtension: 'js' just to see if that changed things and it doesn't, same error.

Note that in my node-modules/ng2-material-dropdown directory (and all sub-dirs) there are no scss files or html files. I see them in the GitHub repo but they aren't there after running npm install --save ng2-material-dropdown.

So these files don't exist at all, it seems, regardless of the extension it is using to try to load them.

Gbuomprisco commented 7 years ago

@jasonburrows I see - but that would fine as the components are all bundled in 1 file. Though I think NPM also does not pull all files, as I actually included them in the dist directory

This is my dist folder (but again - it shouldn't matter):

screen shot 2017-01-03 at 21 58 31

So many issues with SystemJS :( Unfortunately I am not sure how to best help. If it can help I used this boilerplate (https://github.com/mgechev/angular-seed) to test the components with SystemJS

jasonburrows commented 7 years ago

@Gbuomprisco - yeah mine is missing a massive chunk of those files. This is what is in my node_modules/ng2-material-dropdown folder:

screen shot 2017-01-03 at 1 34 27 pm

...maybe someone else will see this and know what I should do about it! Thanks for your help.

johnpankowicz commented 7 years ago

I had the same problem as @jasonburrows. I am also using mgechev/angular-seed. I solved it with this in project.config.ts:

this.addPackageBundles({
    name:'ng2-material-dropdown',
    path:'node_modules/ng2-material-dropdown/dist/ng2-dropdown.bundle'
});