Skip to content
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

Issue/137 add entry point index js #138

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

programarivm
Copy link

All examples have been tested using the new entry point and now some are importing cm-chessboard files from index.js. Closes #137

@programarivm
Copy link
Author

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'

@shaack
Copy link
Owner

shaack commented Mar 9, 2024

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.

@programarivm
Copy link
Author

See #137 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add entry point index.js
2 participants