This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
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
OliverJAsh
reviewed
Apr 27, 2020
import typescript from 'rollup-plugin-typescript2'; | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
|
||
import pkg from './package.json'; |
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.
Nice!
@@ -0,0 +1,20 @@ | |||
import typescript from 'rollup-plugin-typescript2'; | |||
import autoExternal from 'rollup-plugin-auto-external'; |
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.
What does this do in our case? I'm new to Rollup
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.
typescript
runs the code throughtsc
autoExternal
setsdependencies
andpeerDependencies
as external packages so the bundled code leaves them asimport
s. Non-external packages will be bundled in the compiled output.
rollup-plugin-auto-external
could be replaced with an inlined version. It effectively does the following:
import pkg from './package.json'
// Returns a function that returns true if the provided package name is in `externalArr`.
const makeExternalPredicate = externalArr => {
if (externalArr.length === 0) {
return () => false
}
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`)
return id => pattern.test(id)
}
export default {
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' },
],
external: makeExternalPredicate([
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
]),
plugins: [typescript()],
}
These upgrades/additions were remnants from using @rollup/typescript before changing to rollup-plugin-typescript2. rollup-plugin-typescript2 does not require tslib.
When changing the module compiler option to esnext from commonjs, one must also define the correct module resolution strategy.
Trimmed down the PR to just include the Rollup changes. |
OliverJAsh
approved these changes
May 4, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The following changes are done in preparation for #10.
Updates Typescript and adds.tslib
Adds@ts-ignore
inpickTrueObjectKeys
(jump to line). Not sure how to fix the type warning. The code is admittedly too complex for me to understand.