Closed programarivm closed 2 weeks ago
Also by the way the package.json
file could be updated as shown in chesslablab/cmblab in order to define the primary entry point of the library.
...
"module": "./src/index.js",
"browser": "./src/index.js",
...
However, if doing so I'm not too sure about how this would be backward-compatible with previous versions.
import {
Chessboard,
BORDER_TYPE,
FEN
} from 'shaack/cm-chessboard'
I understand that this is your style of doing imports, but I prefer importing from the original files. Maybe because I am from Java and want to keep it simple. For importing the classes from node_modules
or somewhere else, I use importmap
. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
<script type="importmap">
{
"imports": {
"cm-chessboard/": "./node_modules/cm-chessboard/"
}
}
</script>
With defining the module path in importmap
(like above) you can import like this
import {Chessboard, COLOR, INPUT_EVENT_TYPE} from "cm-chessboard/src/Chessboard.js"
What is the reason that you want to put everything in an index.js? This file must also be maintained for changes such as refactoring.
Sorry, I only add things which must be maintained, if it is useful for my projects, mainly https://chessmail.de But anyway thank you for the thoughts on optimizing cm-chessboard. 👍
All examples have been tested using the new entry point and now some are importing
cm-chessboard
files fromindex.js
. Closes https://github.com/shaack/cm-chessboard/issues/137