Skip to main content

Search and Top Navigation

#14375 closed bug (fixed)

Opened August 24, 2015 04:53PM UTC

Closed September 24, 2015 08:51AM UTC

Last modified September 24, 2015 12:10PM UTC

jquery-ui "requirable" as CJS module

Reported by: G-rom Owned by: G-rom
Priority: minor Milestone: 1.12.0
Component: [meta] ui.build Version: 1.11.4
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

Tools like webpack (or browserify, or ...) allow us to use a great range of module syntax (AMD, CJS, global, event ES6 with babel-loader) but

1/ jquery-ui is not up to date on npm see #11101

2/ jquery-ui package.json is not correct and it's missing a "main" section, i.e. "main": "./ui/core.js" or an "index.js" file / module at the root. With this fixed, jquery-ui cannot be required inside a project using modern project builder.

Would appreciate an update of package.json, at least #11101 can be by-passed by using github tarball url, but this one cannot by passed without a fork.

Attachments (0)
Change History (9)

Changed August 24, 2015 04:58PM UTC by G-rom comment:1

Hi,

Tools like webpack (or browserify, or ...) allow us to use a great range of module syntax (AMD, CJS, global, event ES6 with babel-loader) but

1/ jquery-ui is not up to date on npm see #11101

2/ jquery-ui package.json is not correct and it's missing a "main" section, i.e. "main": "./ui/core.js" or an "index.js" file / module at the root. Without this fixed, jquery-ui cannot be required inside a project using modern project builder.

Would appreciate an update of package.json, at least #11101 can be by-passed by using github tarball url, but this one cannot by passed without a fork.

Changed August 24, 2015 05:41PM UTC by scottgonzalez comment:2

owner: → G-rom
status: newpending

There is no main file for jQuery UI. Please clearly explain what you're looking for, or open a PR that shows the requested changes.

Changed August 25, 2015 08:09AM UTC by G-rom comment:3

status: pendingnew

I know there is no main file, but a valid package.json must have one. So you should have a valid package.json or no package.json file at all. In this current state, we cannot use npm & jquery-ui github tarball release

Solutions:

1/ removing the package.json

2/ fix the package.json & add a "main" entry

3/ add an "index.js" module at the package root, seems like it's the default "main" for npm package, but this solution is kind of hackish

Changed August 25, 2015 11:11AM UTC by scottgonzalez comment:4

status: newpending

Replying to [comment:3 G-rom]:

I know there is no main file, but a valid package.json must have one. So you should have a valid package.json or no package.json file at all. In this current state, we cannot use npm & jquery-ui github tarball release

We do have a valid package.json. The main field is *not* required, only name and version are.

Solutions: 1/ removing the package.json

Not at all a solution, we absolutely need package.json, it is our dependency manager.

2/ fix the package.json & add a "main" entry

There's no reasonable entry to add that has been proposed.

3/ add an "index.js" module at the package root, seems like it's the default "main" for npm package, but this solution is kind of hackish

Definitely a hack, especially if it does nothing.

Changed August 25, 2015 03:42PM UTC by G-rom comment:5

status: pendingnew

a "main" entry is not required, if you have an index.js

Keep rejecting all the solutions and jquery-ui will remain unusable by builder relying on node require resolving logic.

Another solution could be to add an index.js which will export a simple object listing all "ui" modules, like

module.exports = {
  accordion: require('./ui/accordion'),
  autocomplete: require('./ui/autocomplete'),
  ...

};

Changed August 25, 2015 03:48PM UTC by G-rom comment:6

In fact, this could be the best solution, this way someone could do

var ui = require('jquery-ui');
var autocomplete = ui.autocomplete

or

var autocomplete = require('jquery-ui/ui/autocomplete');

for a fine grain load and a lighter build

Changed September 18, 2015 07:41PM UTC by scottgonzalez comment:7

Changed September 24, 2015 08:51AM UTC by Jörn Zaefferer comment:8

resolution: → fixed
status: newclosed

Build: Add main entry for webpack support; actual value doesn't matter

Fixes #14375

Closes gh-1600

Changeset: 6308a261fd5d1be2362863e6a59fede4420d9f8c

Changed September 24, 2015 12:10PM UTC by scottgonzalez comment:9

milestone: none1.12.0