#14375 closed bug (fixed)
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.
Change History (9)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
Owner: | set to G-rom |
---|---|
Status: | new → pending |
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.
comment:3 follow-up: 4 Changed 8 years ago by
Status: | pending → new |
---|
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
comment:4 Changed 8 years ago by
Status: | new → pending |
---|
Replying to 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.
comment:5 Changed 8 years ago by
Status: | pending → new |
---|
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'), ... };
comment:6 Changed 8 years ago by
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
comment:8 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Build: Add main entry for webpack support; actual value doesn't matter
Fixes #14375 Closes gh-1600
Changeset: 6308a261fd5d1be2362863e6a59fede4420d9f8c
comment:9 Changed 8 years ago by
Milestone: | none → 1.12.0 |
---|
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.