Skip to content
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

Unable to bundle code with dependencies #243

Open
KevinKWZheng opened this issue Feb 29, 2024 · 5 comments
Open

Unable to bundle code with dependencies #243

KevinKWZheng opened this issue Feb 29, 2024 · 5 comments

Comments

@KevinKWZheng
Copy link

I can properly bundle my code before using this module with Rollup, but now after it is bundled, it gives an error:

Error: Could not dynamically require "./termconfig/xterm.generic.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.

I tried setting dynamicRequireTargets to ./termconfig/xterm.generic.js, but this does not solve the problem

@cronvel
Copy link
Owner

cronvel commented Mar 1, 2024

Before what? After what?

@KevinKWZheng
Copy link
Author

I meant that before I introduce this module into my project, the bundled code could directly by ran by passing in 'node' command. Now it would give the error above

@cronvel
Copy link
Owner

cronvel commented Mar 1, 2024

I'm guessing that you want to use it inside a browser with a terminal emulator.

You have to use ./lib/browser.js as the entry point for your bundler.
You may have to add manually some files to your bundler.
Also due to the nature of Terminal-Kit, it was not meant to be browser-friendly, so good luck.

@KevinKWZheng
Copy link
Author

Actually, no. I am creating a Node command line app. I am trying to use Node 21's single executable file function, so I would need to bundle all my code including external modules into a single file so that I can then compile it.

@cronvel
Copy link
Owner

cronvel commented Mar 1, 2024

Ok, so you need to include all source file manually.
I use extensively lazy-loading, since there is a lot of files, and I like my CLI to start as fast as possible, so all the specific terminal config are not loaded unless used, as well as various rarely used features.

You can use ./lib/termkit-no-lazy-require.js as the entry point, however terminal configs are still loaded dynamicly.
So you should add manually everything contained inside the ./lib/termconfig/ folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants