-
Notifications
You must be signed in to change notification settings - Fork 81
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
Fix missing clip-selector in package, refactor builds #344
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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,46 @@ | ||
import esbuild from 'esbuild'; | ||
import globby from 'globby'; | ||
|
||
const baseConfig = { | ||
target: 'es2019', | ||
logLevel: 'info', | ||
}; | ||
|
||
// ESM | ||
await esbuild.build({ | ||
...baseConfig, | ||
entryPoints: await globby(['src/js/**/*.js']), | ||
format: 'esm', | ||
outdir: 'dist', | ||
}); | ||
|
||
// CJS | ||
await esbuild.build({ | ||
...baseConfig, | ||
entryPoints: await globby(['src/js/**/*.js']), | ||
format: 'cjs', | ||
outdir: 'dist/cjs', | ||
}); | ||
|
||
// IIFE | ||
await esbuild.build({ | ||
...baseConfig, | ||
entryPoints: ['src/js/index.js'], | ||
format: 'iife', | ||
bundle: true, | ||
minify: true, | ||
sourcemap: true, | ||
outdir: 'dist/iife', | ||
globalName: 'MediaChrome', | ||
}); | ||
|
||
// ESM Module | ||
await esbuild.build({ | ||
...baseConfig, | ||
entryPoints: ['src/js/index.js'], | ||
format: 'esm', | ||
bundle: true, | ||
redoPop marked this conversation as resolved.
Show resolved
Hide resolved
|
||
minify: true, | ||
sourcemap: true, | ||
outfile: 'dist/media-chrome.mjs', | ||
}); |
File renamed without changes.
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.
@redoPop thanks for the contribution!
I'd lean more towards keeping the NPM scripts intact and not add an extra dependency
globby
could it work by adding an extra input for media-clip-selector to the NPM scripts?
src/js/extra/*/*.js
the main reason we opted for a JS script for
yarn dev
was that it required a 404 page and redirect which esbuild didn't offer out of the boxThere 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.
Yep, an entry point of
src/js/*.js src/js/*/*.js src/js/*/*/*.js
would work to preserve use of the CLI in package.json (all 3 entry points would be needed for now).Before I go ahead with that change, I'd like to make a quick pitch for some advantages to esbuild's JS API:
@web/test-runner
esbuild.build()
is TypeScripted, which makes it easier to adjust build configurations with IntelliSensetarget
without having to manually change each of the build configs--minify
inbuild:esm-module
No strong feelings on this, and I certainly understand there are other concerns and priorities – just wanted to put in a quick word for it before reverting as I've found it helpful in other projects!
Want to see how a dep-free JS version would look before deciding, or shall we go ahead with the extra entry point in npm scripts?
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.
@redoPop thanks, for now CLI scripts will be sufficient I think.
maybe if we would add more bundles in the future it could become easier but 4 is still ok.
we're also planning to move to jsdelivr for the CDN link install and it might mean we can remove the
esm-module
bundle because jsdelivr nicely bundles and minifies it. unpkg doesn't do this I think.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.
unpkg doesn't bundle but can convert bare esm into full urls
from https://unpkg.com/
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.
Okidoki. Since it's a substantively smaller tweak I'm closing this PR and opened revised PR #351.