Giter Club home page Giter Club logo

Comments (10)

mihar-22 avatar mihar-22 commented on September 21, 2024

👋

I need a little more information if you don't mind.

  1. How are you trying to run it from the root directory?
  2. Why is the project setup this way?

An example repo would help me a lot in understanding what's going on and potentially fixing it.

from svelte-jester.

tom-fletcher avatar tom-fletcher commented on September 21, 2024

By coincidence, I ran into the same issue today. In my case, I had set up a monorepo and was using the Jest projects option to run tests across multiple packages from the root. Sub-packages had their own svelte.config.js, but svelte-jester was failing as it was looking for the svelte.config.js file in the project root only.

Babel handles this by providing the { rootMode: 'upward' } option, which walks up directories until it finds a babel.config.json. A proposed solution is to add a { rootMode: 'upward' } option that walks up from the directory of the current file being transformed until it finds the first svelte.config.js file.

I have an incoming PR for this.

from svelte-jester.

mihar-22 avatar mihar-22 commented on September 21, 2024

Released in 1.1.0, thanks @tom-fletcher and I hope that solves your issues @jamesopstad.

from svelte-jester.

jamesopstad avatar jamesopstad commented on September 21, 2024

Thanks both for working on this. Unfortunately it's currently broken because the svelteconfig.js file is not included in the release. I think it needs to be added to the files entry in the package.json.

from svelte-jester.

tom-fletcher avatar tom-fletcher commented on September 21, 2024

Absolutely right @jamesopstad, svelteconfig.js needs to be in the package.json files pattern for the npm release 😶

@mihar-22 Can we get #14 merged and a release out asap?

from svelte-jester.

mihar-22 avatar mihar-22 commented on September 21, 2024

Released and fixed in 1.1.1, sorry for missing that guys.

from svelte-jester.

tom-fletcher avatar tom-fletcher commented on September 21, 2024

@mihar-22 Thanks, and I was kicking myself when I realised!

@jamesopstad Hopefully this will now allow you run tests from the project root with config files in child folders

Additional monorepo use case

Description

The current implementation stops searching for svelte.config.js when it reaches the cwd. This resolves the issue above when tests are being run from the project root as this is the cwd, however I have found another use case for monorepos:

  • The user wants to have one svelte.config.js in the project root folder and does not want to duplicate this in each of their workspaces
  • Currently, this would work when { rootMode: 'upward' } is set and tests are run from the project root, but would not work when running tests directly from workspace folders
  • The user would have to re-import the root svelte.config.js file into individual svelte.config.js files in each of the workspaces. This creates redundant config files

Resolution

  • This use case can be covered when the { rootMode: 'upward' } option is set by continuing to walk upward from the cwd until it finds a svelte.config.js (or throw an error at the filesystem root)
  • By default (rootMode is not set to upward) svelte.config.js should only be resolved from the project root, and throw an error if not found. This avoids the risk of walking up the directory structure and finding a forgotten svelte.config.js in the home directory, which could cause unexpected errors

I will have a look at this today...

from svelte-jester.

mihar-22 avatar mihar-22 commented on September 21, 2024

Hm ye I see that being a pain. Maybe a separate option? I think 'upward' can walk up to the root and maybe something like 'cwd' can walk up to the current working directory?

from svelte-jester.

tom-fletcher avatar tom-fletcher commented on September 21, 2024

As far as I am aware there isn't any easy way to determine the worktree root of a yarn workspace when you are executing from within it, so the only option is to keep walking up the filesystem. However, this would only be an issue if:

  • The user has set the upward option and
  • The user forgets to put a svelte.config.js in their workspace project or the worktree root above it and
  • The user has a random svelte.config.js file sitting somewhere above their project directory

Note that it stops at the first config file it finds, so it would only go out of the project directory if there weren't any config files above the svelte file being transformed.

I've got a working version that handles both the original and new use cases with just the upward command, and leaves the default to look for the file in the cwd (which doesn't do any walking at all)

from svelte-jester.

jamesopstad avatar jamesopstad commented on September 21, 2024

I'm using the latest 1.1.2 release and can confirm this resolves the issue. Many thanks.

from svelte-jester.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.