weixin_39922683
weixin_39922683
2020-12-28 19:12

Does not work with non-systemjs transpilers

I see "Uncaught ReferenceError: System is not defined"

I am using "bootstrap 4.0.0-alpha.5" for my project. Please suggest if that worked for you.

该提问来源于开源项目:softsimon/ngx-bootstrap-multiselect

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

9条回答

  • weixin_40006185 weixin_40006185 4月前

    I'm getting this error too, though I'm not using Bootstrap 4. In node_modules/angular-2-dropdown-multiselect/src, I noticed the following files: - multiselect-dropdown.html - multiselect-dropdown.ts - multiselect-dropdown.js - multiselect-dropdown.js.map

    I don't think the .js files should be there. I'm little confused about how they're getting downloaded there, because I don't see them in the GitHub repo. Deleting those two files fixes the problem for me, but that's a less than ideal solution.

    点赞 评论 复制链接分享
  • weixin_39895486 weixin_39895486 4月前

    The .js .js.map are there because they are published on NPM to fix #19, but that might have been a bad decision? I am using angular-cli and I am not getting this error as of now.

    点赞 评论 复制链接分享
  • weixin_40006185 weixin_40006185 4月前

    I'm no expert on these things, but I've noticed in many other libraries they have an index.js at the root along with a typescript definition file (index.d.ts). Then those files would reference files in a dist folder. For example: https://github.com/gevgeny/angular2-highcharts. Maybe something like that would work?

    With that said, I did find another way to get it to work without deleting the js files. I simply changed my webpack config file to prioritize ts files first:

    javascript
    resolve: { extensions: ['', '.ts', '.js'] }
    

    instead of:

    javascript
    resolve: { extensions: ['', '.js', '.ts'] }
    
    点赞 评论 复制链接分享
  • weixin_39922683 weixin_39922683 4月前

    , Thanks for your response, But it didn't help me. I get the following error when I change the order in webpack.config.js.

    ERROR in ./~/angular-2-dropdown-multiselect/src/multiselect-dropdown.ts Module build failed: Error: Typescript emitted no output for /Users/chaas003/PTT/src/main/webapp/node_modules/angular-2-dropdown-multiselect/src/multiselect-dropdown.ts at Object.loader (/Users/chaas003/PTT/src/main/webapp/node_modules/ts-loader/index.js:456:15) @ ./src/module/app.module.ts 19:29-95

    点赞 评论 复制链接分享
  • weixin_40006185 weixin_40006185 4月前

    This may explain why you're getting that error if you're using ts-loader to transpile your typescript: https://github.com/TypeStrong/ts-loader/issues/278.

    I'm using awesome-typescript-loader with no problems, so you may want to consider switching to that.

    点赞 评论 复制链接分享
  • weixin_39770416 weixin_39770416 4月前

    Version 0.4.0 works properly with angular2-template-loader and having in resolve.extensions .ts before .js. Thank you guys. I think that shipping package with .ts file is right way.

    点赞 评论 复制链接分享
  • weixin_40003046 weixin_40003046 4月前

    I've updated the exported module to use commonjs instead of systemjs. If you're using webpack, this should resolve your issue. Please try the latest release and let us know if this resolves your problem.

    点赞 评论 复制链接分享
  • weixin_40003046 weixin_40003046 4月前

    No response in 7 days. Assuming the fix worked and closing issue.

    点赞 评论 复制链接分享
  • weixin_39800957 weixin_39800957 4月前

    HI, I am getting below error. Error loading angular-2-dropdown-multiselect/src/multiselect-dropdown can somebody plz help on this. using systemjs.config.js file .

    点赞 评论 复制链接分享

相关推荐