-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Use Rollup to package gridstack.js as an ES Module #1989
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
86edf5c
Add rollup and package as ESM
justinjxzhang 319323d
Merge branch 'gridstack:master' into esm-rollup
justinjxzhang f0c06a5
Use Rollup only for ESM, and build into a separate folder for compati…
justinjxzhang d14fd28
Merge remote-tracking branch 'origin/master' into esm-rollup
justinjxzhang 7501c76
Sync upstream master
justinjxzhang e39b61a
Merge remote-tracking branch 'upstream/master' into esm-rollup
justinjxzhang 0ede1d7
Merge branch 'master' into esm-rollup
adumesny d5bd24a
Delete package-lock.json
adumesny 4ab501b
Delete index.html
adumesny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>Advanced ES Module Demo</title> | ||
|
|
||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> | ||
| <link rel="stylesheet" href="demo.css" /> | ||
|
|
||
| <script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script> | ||
| <script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script> | ||
|
|
||
| <style type="text/css"> | ||
| .grid-stack-item-removing { | ||
| opacity: 0.8; | ||
| filter: blur(5px); | ||
| } | ||
| #trash { | ||
| background: rgba(255, 0, 0, 0.4); | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h1>Advanced ES Module Demo</h1> | ||
| <div class="row"> | ||
| <div class="col-md-2 d-none d-md-block"> | ||
| <div id="trash" style="padding: 5px; margin-bottom: 15px;" class="text-center"> | ||
| <div> | ||
| <ion-icon name="trash" style="font-size: 300%"></ion-icon> | ||
| </div> | ||
| <div> | ||
| <span>Drop here to remove!</span> | ||
| </div> | ||
| </div> | ||
| <div class="newWidget grid-stack-item"> | ||
| <div class="grid-stack-item-content" style="padding: 5px;"> | ||
| <div> | ||
| <ion-icon name="add-circle" style="font-size: 300%"></ion-icon> | ||
| </div> | ||
| <div> | ||
| <span>Drag me in the dashboard!</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="col-sm-12 col-md-10"> | ||
| <div class="grid-stack"></div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import { GridStack } from '../dist/esm/gridstack.js'; | ||
| let grid = GridStack.init({ | ||
| cellHeight: 70, | ||
| acceptWidgets: true, | ||
| dragIn: '.newWidget', // class that can be dragged from outside | ||
| dragInOptions: { revert: 'invalid', scroll: false, appendTo: 'body', helper: 'clone' }, // clone or can be your function | ||
| removable: '#trash', // drag-out delete class | ||
| }); | ||
|
|
||
| let items = [ | ||
| {x: 0, y: 0, w: 4, h: 2, content: '1'}, | ||
| {x: 4, y: 0, w: 4, h: 4, noMove: true, noResize: true, locked: true, content: 'I can\'t be moved or dragged!<br><ion-icon name="ios-lock" style="font-size:300%"></ion-icon>'}, | ||
| {x: 8, y: 0, w: 2, h: 2, minW: 2, noResize: true, content: '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand" style="font-size: 300%"></ion-icon><p class="card-text text-center" style="margin-bottom: 0">...but don\'t resize me!'}, | ||
| {x: 10, y: 0, w: 2, h: 2, content: '4'}, | ||
| {x: 0, y: 2, w: 2, h: 2, content: '5'}, | ||
| {x: 2, y: 2, w: 2, h: 4, content: '6'}, | ||
| {x: 8, y: 2, w: 4, h: 2, content: '7'}, | ||
| {x: 0, y: 4, w: 2, h: 2, content: '8'}, | ||
| {x: 4, y: 4, w: 4, h: 2, content: '9'}, | ||
| {x: 8, y: 4, w: 2, h: 2, content: '10'}, | ||
| {x: 10, y: 4, w: 2, h: 2, content: '11'}, | ||
| ]; | ||
| grid.load(items); | ||
|
|
||
| grid.on('added removed change', function(e, items) { | ||
| let str = ''; | ||
| items.forEach(function(item) { str += ' (x,y)=' + item.x + ',' + item.y; }); | ||
| console.log(e.type + ' ' + items.length + ' items:' + str ); | ||
| }); | ||
| </script> | ||
| </body> | ||
|
|
||
| </html> | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import nodeResolve from '@rollup/plugin-node-resolve'; | ||
| import typescript from '@rollup/plugin-typescript'; | ||
|
|
||
| // rollup.config.js | ||
| /** | ||
| * @type {import('rollup').RollupOptions[]} | ||
| */ | ||
| export default [ | ||
| { | ||
| input: { | ||
| 'gridstack': './src/gridstack.ts' | ||
| }, | ||
| output: { | ||
| format: 'esm', | ||
| dir: './dist/esm', | ||
| sourcemap: true, | ||
| globals: { | ||
| jquery: '$' | ||
| }, | ||
| preserveModules: true | ||
| }, | ||
| plugins: [ | ||
| typescript({ | ||
| tsconfig: './tsconfig.json', | ||
| outDir: './dist/esm', | ||
| module: "esnext", | ||
| declaration: true, | ||
| stripInternal: true, | ||
| }), | ||
| nodeResolve({ | ||
| browser: true, | ||
| }) | ||
| ] | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can you load that ? in Chrome I get:
Access to script at 'file:///C:/depot/gridstack.js/dist/gridstack.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got that too; ended up serving the directory from the root of the repo (i.e.
npx http-server .in/gridstack.js)