Externalized 3rd-party dependencies#192
Merged
rsimon merged 9 commits intorecogito:mainfrom Sep 4, 2025
Merged
Conversation
| output: { | ||
| preserveModules: true, |
Contributor
Author
There was a problem hiding this comment.
I believe that this property is redundant here. Unfortunately, the preserveModules: true doesn't preserve the original file structure of the package in the output, but simply splits it into quite a few chunks. To actually preserve it a more complex config is required, for example:
...
rollupOptions: {
/**
* If you want to convert a set of files to another format while maintaining the file structure
* and export signatures, the recommended way—instead of using output.preserveModules that
* may tree-shake exports as well as emit virtual files created by plugins—is to
* turn every file into an entry point.
* @see https://rollupjs.org/configuration-options/#input
*/
input: Object.fromEntries(
globSync('src/**/*.{ts,tsx}', {
ignore: ['src/**/*.d.ts', 'src/**/*.stories.tsx', 'src/storybook/**/*']
}).map((file) => [
// 1. The name of the entry point
// lib/nested/foo.js becomes nested/foo
relative('src', file.slice(0, file.length - extname(file).length)),
// 2. The absolute path to the entry file
// lib/nested/foo.ts becomes /project/lib/nested/foo.ts
fileURLToPath(new URL(file, import.meta.url))
])
),
...However, I believe it's an overkill for the package, as it still has only a single entry point. Also having the sourcemaps will help the browser to navigate through the original structure.
Comment on lines
+25
to
+32
| globals: { | ||
| 'colord': 'Colord', | ||
| 'uuid': 'UUID', | ||
| 'dequal/lite': 'DequalLite', | ||
| '@annotorious/core': 'AnnotoriousCore', | ||
| 'rbush': "RBush", | ||
| 'hotkeys-js': 'HotkeysJs', | ||
| } |
Contributor
Author
Contributor
Author
|
I also verified that it doesn't break the existing consumers on our side ✅ |
# Conflicts: # package-lock.json # packages/text-annotator-react/package.json # packages/text-annotator/package.json
Member
|
Thanks, I'll give that a try ;-) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Issue
See - #191
Changes Made
vite-plugin-externalize-depsplugin that helps to prevent bundling 3rd-party dependencies. Instead, the consumer should provide them for the packages, so the latter can simply import them.Comparison
@recogito/text-annotator@recogito/react-text-annotator(Soomo Staged)