Skip to content

templates/*/node_modules should be ignored #189

Closed

Description

@AriPerkkio

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'];

Activity

  1. changed the title [-]`template/*/node_modules` should be ignored[/-] [+]`templates/*/node_modules` should be ignored[/+] on Jul 30, 2024
  2. AriPerkkio commented on Jul 30, 2024

    @AriPerkkio
    ContributorAuthor

    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
  3. AriPerkkio commented on Aug 1, 2024

    @AriPerkkio
    ContributorAuthor

    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.

  4. noam-honig commented on Aug 1, 2024

    @noam-honig
    Contributor

    thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy