-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Why does index.js of e.g. cke5-paragraph looks different than that of cke5-highlight #9134
Comments
AFAIK, in our core plugins ( export * from '@ckeditor/ckeditor5-paragraph'; so this is why we are using named exports (but not default export) in the original sources of these plugins, i.e. export { default as Paragraph } from './paragraph';
export { default as ParagraphButtonUI } from './paragraphbuttonui'; In the export { default as Paragraph } from './paragraph';
export { default as ParagraphButtonUI } from './paragraphbuttonui'; to: import Paragraph from './paragraph';
import ParagraphButtonUI from './paragraphbuttonui';
export {
Paragraph,
ParagraphButtonUI
}; all seems to work just fine. But still, this is not a default export, like in other non-core plugins (e.g. AFAIK, it is currently not possible to re-export a default export, because this is currently a Stage 1 Proposal: https://github.com/tc39/proposal-export-default-from. |
The following version is better:
as it makes more sense to have two names exports rather than having one object exported from e.g. highlight:
Ideally, all packages should use the same format that's used in e.g. ckeditor5-pararaph. A question remains – why non-DLL packages use an object? One hyphotesis is that it's because exposing things to There are two methods that we use currently - one for DLLs and one for non-DLLs. The former is defined in webpack.config.dll.js. The latter in https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-utils/lib/builds/getdllpluginwebpackconfig.js#L36-L43. We should check whether using the multiple named exports notation in non-DLLs packages is supported by this webpack's |
If we won't manage to figure out how to unify these index.js files, let's at least document how they should look (and why this way) in the DLL builds guide. There will be a section about writing DLL-compatible plugins. |
Just stumbled upon this again, but from a different angle. WE had a short chat about this with @pomek: Basically, IIRC we went with an object so globalization works out of the box, just like I wrote in one of the above comments:
But I think we need to revisit this. It's too ugly. |
I do not remember every decision we made regarding the DLL topic, so maybe the proposed solution may break something somewhere, but it resolves the main problem. As I already mentioned, I suggested changing the default object export with re-exporting modules. So, replace the following content: ckeditor5/packages/ckeditor5-basic-styles/src/index.js Lines 32 to 54 in dbc9133
with export { default as Bold } from './bold';
export { default as BoldEditing } from './bold/boldediting';
export { default as BoldUI } from './bold/boldui';
export { default as Code } from './code';
export { default as CodeEditing } from './code/codeediting';
export { default as CodeUI } from './code/codeui';
export { default as Italic } from './italic';
export { default as ItalicEditing } from './italic/italicediting';
export { default as ItalicUI } from './italic/italicui';
export { default as Strikethrough } from './strikethrough';
export { default as StrikethroughEditing } from './strikethrough/strikethroughediting';
export { default as StrikethroughUI } from './strikethrough/strikethroughui';
export { default as Subscript } from './subscript';
export { default as SubscriptEditing } from './subscript/subscriptediting';
export { default as SubscriptUI } from './subscript/subscriptui';
export { default as Superscript } from './superscript';
export { default as SuperscriptEditing } from './superscript/superscriptediting';
export { default as SuperscriptUI } from './superscript/superscriptui';
export { default as Underline } from './underline';
export { default as UnderlineEditing } from './underline/underlineediting';
export { default as UnderlineUI } from './underline/underlineui'; Unfortunately, I decided to see what webpack built. The build exports the When the export was defined as It means that I had to analyze the webpack configuration. I found this: output: {
library: [ 'CKEditor5', getGlobalKeyForPackage( packageName ) ],
path: path.join( options.packagePath, 'build' ),
filename: getIndexFileName( packageName ),
libraryTarget: 'window',
libraryExport: 'default'
}, The I guess it resolves the issue. |
Fix (utils): The webpack configuration returned by the `getDllPluginWebpackConfig()` function will not export the default library (`libraryExport`) anymore. See ckeditor/ckeditor5#9134. MAJOR BREAKING CHANGE (utils): The `getDllPluginWebpackConfig()` function will not export the default library anymore.
Fix: All non-DLL packages will re-export their modules instead of exporting the default object with these modules as the object entries. Closes #9134.
Form A:
Form B:
I remember something that we tried to change all B occurrences into A or vice versa but it didn't work. It'd be good to know why.
The text was updated successfully, but these errors were encountered: