-
Notifications
You must be signed in to change notification settings - Fork 610
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
Example of how to use as a node module? #705
Comments
Oddly enough, the authors of this package do not support this use case, see #611 #589 #308 #633
export { Timeline } from './src/js/index.js';
import { Timeline } from '@knight-lab/timelinejs'; To build the CSS, I did this:
when it asks for a version number, hit ctrl-c. import '@knight-lab/timelinejs/dist/css/timeline.css'; The authors of the package seem to be fluent with webpack and the remaining toolchain so I'm a bit at a loss as to why they don't include the prebuilt WFM example: import {useRef, useEffect} from 'react';
import { Timeline } from '@knight-lab/timelinejs';
import '@knight-lab/timelinejs/dist/css/timeline.css';
function App() {
const ref = useRef(null);
useEffect(() => {
if (ref.current != null) {
new Timeline(ref.current, "https://docs.google.com/spreadsheets/d/e/2PACX-1vR5G_GTugmSh6SALnk3Wd3a8J2sp2Z6EJYE3vypBkYQEAxuvxGRyaI6FQe_PAvtDTPblgVOel5Di_9t/pubhtml?gid=0&single=true");
}
}, []);
return (
<div style={{ width: "100%", height: "600px"}} ref={ref} />
);
}
export default App; |
Hi @godmar, thanks for the suggestion. I can't add a file to the node_modules folder, because that folder is created during deployment. But I managed to create a helper JS file in my project containing just: export { Timeline } from '/node_modules/@knight-lab/timelinejs/src/js/index.js'; which I can then import with: import { Timeline } from "../helpers/timelinejs"; I'm not using React, so I'm just manually bundling the CSS in with the rest of my Sass files. This seems to be working, thanks. Leaving the issue open, as this is really an issue that should be resolved properly. |
As the person who adapted TimelineJS into a webpack buildable project, I'm flattered by "The authors of the package seem to be fluent with webpack and the remaining toolchain" but would also need to disclaim it. Put simply, we deploy TimelineJS to NPM mostly because it's easy, and because people had hacked an NPM package from the earlier codebase. We haven't had usecases ourselves to use TimelineJS from NPM, so appreciate feedback, and even pull-requests that make this more useful for the community that needs it. Agreed that this qualifies as an open issue—thanks for raising it—but I don't know when it will move to priority position for Knight Lab. |
You're publishing in the npm registry, so it's somewhat expected that your code will follow the standard conventions used there. Regarding a PR: I can put one together, but please note that it requires changes to your staging script which I may not be able to test due to the fact that the cdn.knightlab.com repository to which it refers is not public. The staging script would need to be split into 2 - one to just build the CSS and other files in the Your current npm seems to already include a bunch of unrelated files, so including the prebuilt I'm actually a bit confused why the |
I added a PR. If I understand things correctly, including the |
I have merged PR #706 and published version 3.8.18 to the npm registry. While I have not tried it from NPM, I created a simple test yesterday modeled off of @godmar's example above after Let us know if this isn't solving the issue. |
Hi
Please can you provide an example of how to use the npm package?
The readme on npmjs.com points to the documentation on the website, but the website doesn't contain any info on using the npm package.
None of the following work:
Thanks
The text was updated successfully, but these errors were encountered: