-
Notifications
You must be signed in to change notification settings - Fork 335
Add an ESM build #414
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
Merged
+69
−70
Merged
Add an ESM build #414
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3bb7a5a
Typo; coding style consistency
joshkel 685946d
Add ESM build
joshkel 25db650
Additional revisions to ESM build
joshkel d4fec2c
Update test configuration to match build configuration
joshkel e709883
Delete 'gulp build' task
joshkel c559685
Switch to named imports
joshkel 45f5d61
Update/clarify comments
joshkel 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 |
---|---|---|
|
@@ -9,5 +9,3 @@ coverage/* | |
|
||
nbproject/* | ||
dist/ | ||
chartjs-plugin-zoom.js | ||
chartjs-plugin-zoom.min.js |
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 |
---|---|---|
|
@@ -10,7 +10,6 @@ var inquirer = require('inquirer'); | |
var semver = require('semver'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var {exec} = require('child_process'); | ||
var karma = require('karma'); | ||
var merge = require('merge-stream'); | ||
var yargs = require('yargs'); | ||
|
@@ -24,17 +23,6 @@ var srcDir = './src/'; | |
var srcFiles = srcDir + '**.js'; | ||
var outDir = './dist/'; | ||
|
||
function run(bin, args, done) { | ||
var exe = '"' + process.execPath + '"'; | ||
var src = require.resolve(bin); | ||
var ps = exec([exe, src].concat(args || []).join(' ')); | ||
|
||
ps.stdout.pipe(process.stdout); | ||
ps.stderr.pipe(process.stderr); | ||
ps.on('close', () => done()); | ||
} | ||
|
||
gulp.task('build', gulp.series(rollupTask, copyDistFilesTask)); | ||
gulp.task('package', packageTask); | ||
gulp.task('bump', bumpTask); | ||
gulp.task('lint-html', lintHtmlTask); | ||
|
@@ -43,20 +31,7 @@ gulp.task('lint', gulp.parallel('lint-html', 'lint-js')); | |
gulp.task('unittest', unittestTask); | ||
gulp.task('test', gulp.parallel('lint', 'unittest')); | ||
gulp.task('watch', watchTask); | ||
gulp.task('default', gulp.parallel('lint', 'build', 'watch')); | ||
|
||
function rollupTask(done) { | ||
run('rollup/dist/bin/rollup', ['-c'], done); | ||
} | ||
|
||
/** | ||
* Copy the files from `/dist` to the root directory. | ||
* @todo remove at version 1.0 | ||
*/ | ||
function copyDistFilesTask() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing this will break |
||
return gulp.src(outDir + '*.js') | ||
.pipe(gulp.dest('./')); | ||
} | ||
gulp.task('default', gulp.parallel('lint', 'watch')); | ||
|
||
function packageTask() { | ||
return merge( | ||
|
@@ -151,5 +126,5 @@ function unittestTask(done) { | |
} | ||
|
||
function watchTask() { | ||
return gulp.watch(srcFiles, gulp.parallel('lint', 'build')); | ||
return gulp.watch(srcFiles, gulp.parallel('lint')); | ||
} |
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
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 @@ | ||
export {default as Zoom} from './plugin'; |
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,6 @@ | ||
import {Chart} from 'chart.js'; | ||
import Zoom from './plugin'; | ||
|
||
Chart.register(Zoom); | ||
|
||
export default Zoom; |
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
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.
you should probably leave these and add the esm files as well for packaging. see my other comment below
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.
If I'm understanding correctly, we don't need these .gitignore lines or the gulpfile
copyDistFilesTask
.The previous configuration invoked Rollup to put the files under
dist
, then it calledcopyDistFilesTask
to copy the files out ofdist
into the project root (which is why the files are listed in .gitignore here). But package.json references the copies underdist
directory, and the gulpfile'spackageTask
references the copies underdist
(viaoutDir
). I can't tell that the copies in the project root are used at all, so I removed them.If I've missed something, please let me know.
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.
gulp package
looks like it looks for files in the root directory:chartjs-plugin-zoom/gulpfile.js
Line 64 in 8194ad6
Alternatively, you might be able to update
gulp package
to look indist
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.
If I'm understanding Gulp correctly, it treats
outDir
as the glob base foroutDir + '*.js'
, so the files fromdist
are included at the top level of the resulting zip file. Contrast with the explicitbase
parameter for thesamples
glob; those are included in asamples
subdirectory within the zip file:chartjs-plugin-zoom/gulpfile.js
Line 68 in 8194ad6
I tested by running
npm run build; npx gulp package
in a fresh copy of my branch, and it created adist/chartjs-plugin-zoom.zip
file with contents similar to the releases on GitHub, so I think things are working.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.
Ah, we might need to update the comments in the
packageTask
as they threw me off and look like they might be outdated: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.
Yes, I found that confusing too. I just pushed some comments to try and clarify; feedback welcome.