-
Notifications
You must be signed in to change notification settings - Fork 8
Externalized 3rd-party dependencies #192
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
base: main
Are you sure you want to change the base?
Externalized 3rd-party dependencies #192
Conversation
output: { | ||
preserveModules: true, |
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 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.
globals: { | ||
'colord': 'Colord', | ||
'uuid': 'UUID', | ||
'dequal/lite': 'DequalLite', | ||
'@annotorious/core': 'AnnotoriousCore', | ||
'rbush': "RBush", | ||
'hotkeys-js': 'HotkeysJs', | ||
} |
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 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
Issue
See - #191
Changes Made
vite-plugin-externalize-deps
plugin 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)