Skip to content

Commit

Permalink
Merge pull request #16439 from ckeditor/ck/16257-add-fields-to-packag…
Browse files Browse the repository at this point in the history
…e.json-file

Other (ckeditor5): Add `main`, `module`, `types` and `exports` fields to `package.json` file. Closes #16257.
  • Loading branch information
filipsobol authored May 29, 2024
2 parents b7919d6 + c98ab48 commit 67117fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/release/preparepackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const tasks = new Listr( [
return releaseTools.prepareRepository( {
outputDirectory: RELEASE_DIRECTORY,
packagesDirectory: PACKAGES_DIRECTORY,
rootPackageJson: getCKEditor5PackageJson( cliArguments.nightly ),
rootPackageJson: getCKEditor5PackageJson(),
packagesToCopy: cliArguments.packages
} );
}
Expand Down
42 changes: 14 additions & 28 deletions scripts/release/utils/getckeditor5packagejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@ const upath = require( 'upath' );
* @param {Boolean} isNightly
* @returns {Object}
*/
module.exports = function getCKEditor5PackageJson( isNightly = false ) {
module.exports = function getCKEditor5PackageJson() {
const pkgJson = fs.readJsonSync(
upath.join( __dirname, '..', '..', '..', 'package.json' )
);

const content = {
return {
name: pkgJson.name,
version: pkgJson.version,
keywords: pkgJson.keywords,
description: 'A set of ready-to-use rich text editors created with a powerful framework.' +
' Made with real-time collaborative editing in mind.',
type: 'module',
main: 'dist/index.js',
module: 'dist/index.js',
types: 'dist/types/index.d.ts',
exports: {
'.': {
'types': './dist/types/index.d.ts',
'import': './dist/index.js'
},
'./translations/*.js': {
'types': './dist/translations/*.d.ts',
'import': './dist/translations/*.js'
},
'./*.css': './dist/*.css',
'./build/*': './build/*',
'./src/*': './src/*',
'./package.json': './package.json'
Expand Down Expand Up @@ -54,30 +66,4 @@ module.exports = function getCKEditor5PackageJson( isNightly = false ) {
'README.md'
]
};

if ( isNightly ) {
/**
* TODO: Add to the returned object once we are ready for a final release.
*
* https://github.com/ckeditor/ckeditor5/issues/16257.
*/

content.main = 'dist/index.js';
content.module = 'dist/index.js';
content.types = 'dist/types/index.d.ts';
content.exports = {
'.': {
'types': './dist/types/index.d.ts',
'import': './dist/index.js'
},
'./translations/*.js': {
'types': './dist/translations/*.d.ts',
'import': './dist/translations/*.js'
},
'./*.css': './dist/*.css',
...content.exports
};
}

return content;
};

0 comments on commit 67117fb

Please sign in to comment.