-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Support for package.xxxx (dedicated) #41927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A living example to see the differences: package.json{
"name": "@ltd/j-toml"
,
"description": "An implementation of TOML written by LongTengDao. Belong to \"Plan J\"./龙腾道为汤小明语写的实现。从属于“简计划”。"
,
"version": "1.28.0"
,
"license": "LGPL-3.0"
,
"author": "龙腾道 <[email protected]> (www.LongTengDao.com)"
,
"bugs": "https://GitHub.com/LongTengDao/j-toml/issues"
,
"repository": { "type": "git", "url": "https://GitHub.com/LongTengDao/j-toml.git" }
,
"keywords": [ "TOML", "stringify", "parse", "1.0.0", "0.5.0", "0.4.0", "0.3.0", "0.2.0", "0.1.0" ]
,
"homepage": "https://www.npmjs.com/package/@ltd/j-toml"
,
"files": [
"package.json"
,
"index.d.ts"
,
"index.js"
,
"index.js.map"
,
"index.d.mts"
,
"index.mjs"
,
"index.mjs.map"
,
"test.js"
,
".editorconfig"
,
"LICENSE"
,
"README.md"
,
"CHANGELOG.md"
]
,
"scripts": {
"test": "node ./test.js"
}
,
"exports": {
"import": {
"types": "./index.d.mts"
,
"default": "./index.mjs"
}
,
"require": {
"types": "./index.d.ts"
,
"default": "./index.js"
}
}
} package.json5{
name: '@ltd/j-toml',
description: 'An implementation of TOML written by LongTengDao. Belong to "Plan J"./龙腾道为汤小明语写的实现。从属于“简计划”。',
version: '1.28.0',
license: 'LGPL-3.0',
author: '龙腾道 <[email protected]> (www.LongTengDao.com)',
bugs: 'https://GitHub.com/LongTengDao/j-toml/issues',
repository: { type: 'git', url: 'https://GitHub.com/LongTengDao/j-toml.git' },
keywords: [ 'TOML', 'stringify', 'parse', '1.0.0', '0.5.0', '0.4.0', '0.3.0', '0.2.0', '0.1.0' ],
homepage: 'https://www.npmjs.com/package/@ltd/j-toml',
files: [
'package.json',
'index.d.ts',
'index.js',
'index.js.map',
'index.d.mts',
'index.mjs',
'index.mjs.map',
'test.js',
'.editorconfig',
'LICENSE',
'README.md',
'CHANGELOG.md',
],
scripts: {
test: 'node ./test.js',
},
exports: {
import: {
types: './index.d.mts',
default: './index.mjs',
},
require: {
types: './index.d.ts',
default: './index.js',
},
},
} package.yamlname: '@ltd/j-toml'
description: 'An implementation of TOML written by LongTengDao. Belong to "Plan J"./龙腾道为汤小明语写的实现。从属于“简计划”。'
version: 1.28.0
license: LGPL-3.0
author: '龙腾道 <[email protected]> (www.LongTengDao.com)'
bugs: https://GitHub.com/LongTengDao/j-toml/issues
repository: { type: 'git', url: 'https://GitHub.com/LongTengDao/j-toml.git' }
keywords: [ TOML, stringify, parse, 1.0.0, 0.5.0, 0.4.0, 0.3.0, 0.2.0, 0.1.0 ]
homepage: https://www.npmjs.com/package/@ltd/j-toml
files:
- package.json
- index.d.ts
- index.js
- index.js.map
- index.d.mts
- index.mjs
- index.mjs.map
- test.js
- .editorconfig
- LICENSE
- README.md
- CHANGELOG.md
scripts:
test: 'node ./test.js'
exports:
import:
types : ./index.d.mts
default: ./index.mjs
require:
types : ./index.d.ts
default: ./index.js
package.tomlname = '@ltd/j-toml'
description = """
An implementation of TOML written by LongTengDao. Belong to "Plan J".\
/\
龙腾道为汤小明语写的实现。从属于“简计划”。\
"""
version = '1.28.0'
license = 'LGPL-3.0'
author = '龙腾道 <[email protected]> (www.LongTengDao.com)'
bugs = 'https://GitHub.com/LongTengDao/j-toml/issues'
repository = { type = 'git', url = 'https://GitHub.com/LongTengDao/j-toml.git' }
keywords = [ 'TOML', 'stringify', 'parse', '1.0.0', '0.5.0', '0.4.0', '0.3.0', '0.2.0', '0.1.0' ]
homepage = 'https://www.npmjs.com/package/@ltd/j-toml'
files = [
'package.json',
'index.d.ts',
'index.js',
'index.js.map',
'index.d.mts',
'index.mjs',
'index.mjs.map',
'test.js',
'.editorconfig',
'LICENSE',
'README.md',
'CHANGELOG.md',
]
[scripts]
test = 'node ./test.js'
[exports]
import.types = './index.d.mts'
import.default = './index.mjs'
require.types = './index.d.ts'
require.default = './index.js'
|
Even if I would love to have native TOML support in JS, I'm afraid {
"name": "@ltd/j-toml",
"exports": {
"import": {
"types": "./index.d.mts",
"default": "./index.mjs"
},
"require": {
"types": "./index.d.ts",
"default": "./index.js"
}
}
} Many other tools in the ecosystem also expect to find a A more realistic approach would be to create a script that translates your
FYI Node.js also needs to support ESM, which does no extension searching (meaning you would have to do |
Indeed there could be problems for node to do this, and I also think this proposal rarely has chance to become true. I still open this, half because json's problem, and half because, every ecosystem has a root. Maybe it's hard to lead ecosystem move on, but if node can't, nobody can. The other tool stacks of our ecosystem just watch npm and node, and npm will watch node. I can't image, there will be an easier position than node to do this. |
I'll try not to make the subject too philosophical, but
If you feel like it's something that's worth the effort, you can make it happen as long as no one objects. My guess though is that the majority of Node.js community thinks that JSON is not problematic enough to be worth it (I also think so). |
@aduh95 Thank you to crystallize the challenges for this! It seems that, only support multiple formats for package, won't be much less difficulty than supporting for require/import all. I close this issue. Maybe one day these question I have good answers, I will reopen this. Currently, I only wrote translation, tutorial and implementation for TOML, that's too few to achieve this purpose. |
Uh oh!
There was an error while loading. Please reload this page.
What is the problem this feature will solve?
JSON is a good data transfer and built-in-js format.
But:
The related issue #40714 which is closed maybe request too much, too heavy change, including both parse and stringify, package even import/require/JSON.parse.
But in fact, the stringify and import/require/JSON.parse is almost impossible to reach, and also no big necessity. People should better do that via 3rd party runtime lib, even compiling plugins.
Is it possible, that we just support other format like JSON5/YAML/TOML, just in package.xxxx?
What is the feature you are proposing to solve the problem?
Add support for
package.json5
/package.yaml
/package.toml
in Node. It means same effect for "main" and other functional fields withpackage.json
.People can
require('./package')
, or simply not support that. When people do that for a libary, of cause they should read the package's docs. This can be discussed.No more.
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: