Giter Site home page Giter Site logo

Comments (7)

iangregsondev avatar iangregsondev commented on July 1, 2024 3

Hi, ok thanks I will try that. I did that previously because i wanted a cleaner import - so i am able to do the following.

(i dont export every file to the root index.js)

import { MyData } from "@MyComp/MyPackage/data

publishing the dist folder - even with the main "dist/index.js" means that if i wanted to do the above then i would need to do

import { MyData } from "@MyComp/MyPackage/dist/data

notice the dist in the import ?

Maybe i should just export everything inside of the dist/index.js

so i can do a cleaner import, before I stopped exporting everything in the root index.js as it was getting real messy BUT of course now I have the ability to use microservices etc...

from npm.

pvdlg avatar pvdlg commented on July 1, 2024 2

Why are you trying to publish from dist? Shouldn't you publish the dist directory from the root of your project?

Typically a project with compiled files would have the following in the package.json:

{
  "files": ["dist/**"],
  "main": "dist/index.js"
}

And publish from the root of the project.

In your situation publishing from dist would make things a lot complex and risky. You would have to copy every files that need to be included in the package into dist. That includes .npmignore, .gitignore, README.md, CHANGELOG.md, LICENSE, maybe some documentation and potentially many other files. That's risky because if you add a new file in your project it would be really easy to forget to copy and publish a release without it.

from npm.

soymikey avatar soymikey commented on July 1, 2024 1

That happened to me as well, so i work around with configure package.json file. My configuration: "bin": { "cli": "dist/bin/cli.js" }

from npm.

iangregsondev avatar iangregsondev commented on July 1, 2024

I hope I am attempting this correctly? Basically, I would like to publish to NPM only the DIST directory as this is where all my compiled files are.

from npm.

pvdlg avatar pvdlg commented on July 1, 2024

What is typically done in node modules is to have an index.js that exposes the public parts of your API (the stuff that you can require from other modules).

Something like that:

module.exports = {someFunction, SomeClass, someOtherFunction};

Those thing you export in index.js can come from anywhere internally in your project.

from npm.

iangregsondev avatar iangregsondev commented on July 1, 2024

Thanks, yes I am going to return to this way of doing things, I think i changed for all the wrong reasons. Now I am using nestjs - its got way more structure and I am able to abstract a lot of the stuff I am doing right now - into microservices.

So it seems a good time to do it.

Thanks again

from npm.

ryanrosello-og avatar ryanrosello-og commented on July 1, 2024

I ran into this problem just now, took me a little while to figure it out. My problem was trying to be fancy and importing the package.json to scrape the name and version of the package.

fixed by removing it for now:

2023-12-09_20-16-20

from npm.

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.