Is it more suitable for a svelte package to be listed as a dependency or a devDependency in

There have been numerous discussions about the distinction between dependency and devDependency, but none specifically address this topic in relation to svelte. So, let's dive into it here.

In many svelte packages like svelte-material-ui or svelte-routing, the instructions recommend installing the package as a dependency. However, since svelte compiles these packages during build time, any new library using them does not need to install the svelte package. This raises the question of why it is required as a dependency.

This may be subjective, but it would be beneficial to get some insights on the preferable approach.

Answer №1

When working with SvelteKit, the upcoming version of Sapper, one key distinction exists between using dependency and devDependency: any module utilized in a (server-side) endpoint must be classified as a dependency. Failure to do so could result in issues when deploying the project on a serverless platform, although it will function correctly locally.

On the other hand, my personal preference leans towards designating everything as a devDependency. This choice stems from the fact that Svelte acts as a compiler, requiring packages solely during compile-time. Nevertheless, there is no harm in labeling all dependencies as such for ease of management.

Answer №2

In my opinion, the importance of distinguishing between devDependencies and dependencies in a web project is subjective. If you're not planning to distribute your code as an NPM package, the difference may not be significant. You can refer to this relevant discussion for more insights.

Based on my experience with web development projects, it's beneficial to categorize dependencies based on whether they are used for building/testing (devDependencies) or "used at runtime" (dependencies). While Svelte doesn't utilize literal code at runtime, designating everything as devDependency may not provide a clear separation.

You can explore NPM documentation which suggests differentiating between production and development/testing dependencies.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to nest arrays within arrays in JavaScript?

Array ( [0] => Array ( [contactId] => 5 [companyId] => 54 [personName] => Awais [contactNo] => 0321-1111111 [contactType] => Partner ) ) data[0].personName I ...

React Transition Group failing to apply CSS classes

I am utilizing React Transition Group to apply animations with different timeouts to each item. However, the issue arises when my links do not receive any classes. Despite this, wrapping the ScrollLinks tag with TransitionGroup allows the animation to func ...

When attempting to retrieve the value of a textbox using JavaScript, the outcome may sometimes be null

Here is the code: <input name="xy" size="2" type="text" /> The above input tag is supposed to create a textbox that looks and acts like one. When using JavaScript as shown below: alert(document.getElementById("xy")); the alert returns null. De ...

Node.js (Express), passport.js, mongoose.js, and Android app all have in common the HTTP Error 307 - Temporary redirect

I am currently constructing a REST Api using Node.js (Express.js and Moongose.js). I have a single post route that takes JSON data and redirects it to the signup page (/app/signup) if the user is a first-time user (not found in the database), or to the log ...

Challenge with Dependency Injection in the Handlers of NestJS CQRS repositories

As a newcomer to nodejs, I am currently delving into the implementation of NestJS's CQRS 'recipe'. In my service, I have a Request scoped with the injection of QueryBus: @Injectable({scope: Scope.REQUEST}) export class CustomerService { co ...

Using jQuery to toggle visibility of various elements without needing specific identifiers

I have coded a HTML and JS snippet for displaying and hiding a div element, which is currently functioning correctly. However, I want to be able to use multiple boxes on a single page and I need a way to determine which box-header was clicked. Is there a ...

Exploring Three.js: How to Integrate and Utilize 3D Models

Hey there! I've been doing a lot of research online, but I can't seem to find a solution that works for me. My question is: How can I integrate 3D models like collada, stl, obj, and then manipulate them using commands like model.position.rotation ...

I am perplexed by the driver's inability to locate the element

Check out this webpage for the latest updates: I am attempting to extract data on EPS, EPS beat, GEPS, GEPS beat, and revenue from this site. List1 = driver.find_element_by_xpath("""/html/body/div[2]/div[1]/div/main/div[2]/div[3]/div[2]/sec ...

Manipulating data in a deeply nested field of an embedded document using Mongoose, MongoDB, and Express

I have been pondering whether it is feasible to input data into the comments field of my "TopicSchema": var mongoose = require('mongoose'); var TopicSchema = new mongoose.Schema({ username: String, topic: String, des ...

What are the steps to modify the source of a Javascript audio object?

I'm in the process of developing a customized HTML5 audio player. Within my script, I currently have the following code snippet. var curAudio = new Audio('Audio.mp3'); $("#play").on("click", function(e) { e.preventDefault(); curAudi ...

Uploading files in NodeJS using the multer library

I am attempting to upload a file to a specific directory on the disk using the multer library. As I analyze the code, it seems that when a request is made, the file is taken from it and saved separately from the rest of the request. Is there a way to acces ...

Numerous occurrences of Vue-Chartjs

My goal is to incorporate multiple Doughnut type graphs into a single component. Resource: <div class="row"> <div class="col-12 col-lg-6"> <strong>All</strong> <Doughnut chart-id="wor ...

Experience the mesmerizing motion of a D3.js Bar Chart as it ascends from the bottom to the top. Feel free to

Here is the snippet of code I am working with. Please check the link for the output graph demonstration. [Click here to view the output graph demo][1] (The current animation in the output is from top to bottom) I want to animate the bars from Bottom to ...

Using a jQuery script, you can enable a back button functionality that allows users

I created a survey to assist individuals in determining where to go based on the type of ticket they have. However, I am currently facing difficulties with implementing a "Back" button that will display the previous screen or "ul" that the user saw. Initia ...

Mongooses do not clutter the array with unnecessary lines

I need help generating a sorted list from the database. Here is my current code: const subs = await Sub.find({}, {userName: 1, score: 1, _id: 0}).sort({ score: 'desc' }); The output I am getting looks like this: { userName: 'test1', ...

Assign an Angular model to an input in a dynamic manner

Currently, I am working on developing a compact spreadsheet feature for my angular application. My goal is to replicate a common functionality found in spreadsheets where users can click on a cell and then modify its value using a larger input field at the ...

Expanding a div's size with CSS to fill the remaining space

Here's the setup I'm working with: <div class="parent"> <div class="moverBoy"></div> <div class="smartBoy"></div> </div> The parent element is fixed at 100x20 indefinitely. moverBoy and smartBoy are al ...

Why isn't nesting directives working in AngularJS?

I am facing an issue with one parent directive and multiple child directives. My requirement is to nest one directive inside another, resulting in the use of multiple directives. Could someone assist me in identifying any errors in this code or provide e ...

Interested in learning how to code games using JavaScript?

Hi everyone, I'm currently exploring the world of Javascript and have been tasked with completing a game for a class project. The game involves a truck that must catch falling kiwis while only being able to move left or right. A timer is set for two m ...

No default export function available on this page

Recently delving into Nextjs, I'm currently in the process of setting up a MongoDB connection using middleware configuration. Let me showcase my code: import type { NextApiRequest, NextApiResponse } from 'next' import { connectMongoDB } fro ...