Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #13812
Closed
Open
Issue created Jun 13, 2014 by Administrator@rootContributor

AMD with concatenated JS file

Created by: hnrch02

The problem is that you can only have one define call within the same file, unless you specify a name that substitutes the file name which would normal determine the name of the module. This is currently not the case with our UMD code and makes the concatenated JS file not work with AMD.

I did some more tinkering with this and came to the conclusion that we have two options:

  1. We process the source files in the concatenation step to replace part of the UMD code to look like this:
typeof define == 'function' && define.amd ? define('bs.<PLUGIN_NAME>', ['jquery'], o_o)

This would solve the problem, but create a new one: You'd need to require all plugins individually like so:

require(['jquery', 'bs.affix', 'bs.alert', ...], function ($) {
  !!$.fn.affix // -> true
})
  1. We process the source files in the concatenation step to replace part of the UMD code to look like this:
typeof define == 'function' && define.amd && typeof require == 'function' ? require(['jquery'], o_o)

Then you'd require Bootstrap like this and you'd be good to go:

require(['jquery', 'bootstrap'], function ($) {
  !!$.fn.affix // -> true
})

I prefer option 2, but I don't know if that has downsides. I can't think of any, as we're not exporting anything that could be used in the require call by the end user.

/cc @fat @cvrebert @XhmikosR

Assignee
Assign to
Time tracking