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

templates/*/node_modules should be ignored #189

Closed
AriPerkkio opened this issue Jul 30, 2024 · 3 comments · Fixed by #198
Closed

templates/*/node_modules should be ignored #189

AriPerkkio opened this issue Jul 30, 2024 · 3 comments · Fixed by #198
Labels
bug Something isn't working

Comments

@AriPerkkio
Copy link
Member

AriPerkkio commented Jul 30, 2024

Describe the bug

If template's node_modules is present, these are copied to webcontainer. This can easily lead into copying 10s of megabytes of content. Also platform specific modules will not work as they are not using wasm builds of native modules.

Steps to reproduce

  1. npm create tutorial
  2. cd src/templates/default; npm install
  3. Start dev server
  4. Preview fails to load

Expected behavior

node_modules should be excluded by default.

Screenshots


Platform

  • TutorialKit version: 0.1.1

Additional

export const IGNORED_FILES = ['**/.DS_Store', '**/*.swp'];

@AriPerkkio AriPerkkio added the bug Something isn't working label Jul 30, 2024
@AriPerkkio AriPerkkio changed the title template/*/node_modules should be ignored templates/*/node_modules should be ignored Jul 30, 2024
@AriPerkkio
Copy link
Member Author

Though it's completely valid use case to add pre-optimized node_modules into templates to make tutorials load faster.

To get the best user experience here, we should ignore templates/*/node_modules by default. Including templates/*/node_modules should be possible by opt-in option. Maybe after #165 we could have:

template:
  name: my-template
  ignoredFiles: [] # Defaults to '**/node_modules**/', [] makes node_modules included

@AriPerkkio
Copy link
Member Author

So far I've tried two approaches:

  • Add template.ignoredFiles into metadata
    • This way we would still end up creating those 50MB <name>-template.json files, as exclusion would happen after the files have been loaded to the browser
  • Add ignoredFiles to .tk-config file, that is already used to configure src/templates
    • This would work well, but now it's not possible to set this in tutorial/part/chapter/lesson metadata
    • Implementing this into codebase is also a bit difficult now, but possible

More users are now running into this so we should publish a release with quick fix as soon as possible. I think I'll make node_modules exclusion non-configurable now, and create a separate feature issue for configuring ignoredFile in metadata or .tk-config.json.

@noam-honig
Copy link
Contributor

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants