Giter Club home page Giter Club logo

Comments (11)

dpilafian avatar dpilafian commented on July 23, 2024 2

I think PR #29 (Compile to umd with browserify) for Issue #15 may resolve this.

The new file:

dist/umd/simple-datatables.js (36k)

should show up at:
https://www.jsdelivr.com/package/npm/simple-datatables?path=dist

Then you could hit the CDN with something like:

<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/[email protected]/dist/style.css>
<script src=https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/simple-datatables.js></script>

Because of the UMD wrapper, you instantiate like this:

const dataTable = new simpleDatatables.DataTable(elem, config);

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024 1

@rigwild The package that is currently provided is transpiled using buble. Is that not good enough?

Do you have any preference for how the CDN version should be packaged? Would https://unpkg.com/ be an acceptable option?

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024 1

@rigwild Thanks, I updated the readme for 2.1.4. So with this I assume this issue has been fixed and I'll close it. Please reopen if this is not the case.

from simple-datatables.

rigwild avatar rigwild commented on July 23, 2024

I didn't see that the package was transpiled, sorry.
unpkg is great. You also have https://www.jsdelivr.com/, but both are equally good CDNs.

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024

@rigwild Is jsdelivr set up automatically so that https://cdn.jsdelivr.net/npm/simple-datatables works already?

from simple-datatables.

rigwild avatar rigwild commented on July 23, 2024

Looks like it! Adding this link to the README.md would be a nice addition.

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024

If this is something you are using, it would be good to find out if the dynamic import is working before listing it. Try to check if you can sort anything by date. That should dynamically load an extra file. That seems to be tricky in some setups. See #14 .

from simple-datatables.

rigwild avatar rigwild commented on July 23, 2024

I spoke too soon. It does not work.

simple-datatables:5 Uncaught ReferenceError: exports is not defined

see: https://codepen.io/anon/pen/qGawej

There's a workaround making it work (but it's a bit hacky), but the date sorting does not work as require is used :

<script>var exports = {}</script>

Maybe format: 'iife' in rollup.config.js is what we are looking for ? (I don't know rollup so I can't provide a PR 😞 )
see: https://rollupjs.org/guide/en#output-format

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024

@rigwild See the discussion in #14 - iife does not work for rollup under the current circumstances. But maybe we an switch to webpack?

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 23, 2024

@dpilafian I think you may be right. I have added the required extra fields in package.json so that it should be served on both unpkg and jsdelivr at https://cdn.jsdelivr.net/npm/simple-datatables and https://unpkg.com/simple-datatables . However I haven't tested this, so please do before we close this ticket. Also, it is still serving me the 2.1.1 version unless I manually specify that I want version 2.1.3. I have tried in several browsers, and from the documentation on those websites I don't really see how to invalidate the CDN's cache. I hope it does so automatically eventually. Else we'll need to change the URLs in the readme.

from simple-datatables.

rigwild avatar rigwild commented on July 23, 2024

It actually works!
See: https://codepen.io/anon/pen/vwvWwg

For URLs, the trick seems to be to use the @latest tag instead of the version number (or nothing).

Don't forget to add the CSS too.

<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>

from simple-datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.