-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Discussion: Use of NPM modules within deno #1397
Comments
Nice! I don't think there are discussions about polyfills yet, but I did create some org aiming to host ported packages from node to deno. Polyfills would definitely be an interesting topic to work on and we could probably create a repo specially for that. About registry, there is the deno.land/x/ for redirection of scripts hosted elsewhere, but they are specifically for modules written solely for deno and is similar to |
@kevinkassimo Is there any chat (slack, discord, gitter) service we're using where I can bounce ideas. I create a new set of proposals and thoughts and I'd like some feedback. Seems like this issue should be closed but I'd like to talk about polyfills, npm -> deno, and deno -> npm. |
@reggi we hang around on gitter: https://gitter.im/denolife/Lobby |
I discovered https://jspm.io/ which is basically unpkg but modifies the code to be usable with browser-native ES modules. It's not yet compatible with deno because it uses extensionless URLs but that could be pretty easily fixed. See jspm/project#44. |
Idea for NPM modules to work with DENO (optimally)I'm trying to find a way to bundle a NPM module but preserve it's integrity, not just one webpack bundle for all the deps within, possibly duplicating the dep tree. Essentially, I've been trying to figure out to have my cake and eat it too. What I want is to be able to take a For instance, I install The thing that is hard to figure out is a module I created a webpack bundler to export bundles of every individual file. SO it's not one massive bundle of the package I want, the idea being that if two packages use the same module, It's smaller file sizes used. With this method, the issue being if I snapshot What I want is to be able to target:
Where the hash after the version is [ a hash, of a JSON file, (sorted keys and minified) of all the absolute version dependencies in the entire tree ]. The idea here being is that I've developed a way to wrap every JS file and "uptranspile" (js to ts) it to use What I'm thinking about is some dynamic way to pull in this hash from the server import DenoDependency as 'https://ts.reggi.com/DenoDependency/1.0.0.json'
import * from depencencies as 'https://ts.reggi.com/lodash/tree/8f60c8102d29fcd525162d02eed4566b.json'
export default import(DenoDependency(depencencies)).then({
lodash, graphql, etc
} => {
}) But I can't export from within this import, and import can't be a template string/variable directly. This is where top-level async await can be utilized because nobody is going to want to Been thinking non-stop about deno->npm and npm->deno would love to talk with someone else who shares these thoughts. Idea For Deno authored files to work with NPMFor every typescript file on a server, we have a npm install https://ts.reggi.com/meow_mix.git import meowMix from https://ts.reggi.com/meow_mix.ts RealityOf course, this doesn't help if there are native node modules, or deno_std modules because that code will not be compatible until polyfills are made. |
Ok, I just had an interesting thought. My main issue is that I'm creating a version of |
@reggi Go 1.11's new module system works like that. (Also, if you have two dependencies that both depend on a third dependency with the same major version number, like A depends on C 1.1.0 and B depends on C 1.2.0, then the only C 1.x version that will be used will be 1.2.0.) |
@reggi Resolving to the oldest dependency version is still prone to inconsistencies as well, as the oldest version of a module might disappear over time, so that someone asking for the oldest version in the future might get a result. Modules might be removed for serious security issues, legal issues, or major bugs. The whole goal of minor version bumps is to add compatible features and bug fixes, so it generally seems safer to resolve towards newer versions. I think But to address the original issue about NPM compatibility, I'll ask a naive newercomer question: Is it possible to add a top-level |
I think deno should do whatever it takes to support the npm registry and all its packages out of the box. I think it's going to be hard to gain traction and make the project successful otherwise. |
Agreed. Without a clear migration path, This could drag on forever like Perl 5 vs Perl 6 or Python 2 vs Python 3. The |
@biels I mostly agree, but at the same time maybe adopting npm packages isn't the best idea for the overall scope of deno? Maybe starting fresh isn't the worse idea. It would be cool if their was some sort of portability between the two in the meantime to get steam rolling. I am sure @ry has addressed this somewhere else or has a better explanation than I. |
With GitHub packages just begging to be the 'next big thing' in the JavaScript ecosystem, I think it becomes even more important to gain at least some level of compatibility with the system. |
Import maps and unpkg, IMHO, seems like a shim for npm.
…On Wed, 15 May 2019, 17:09 Jonas Gierer, ***@***.***> wrote:
With GitHub packages just begging to be the 'next big thing' in the
JavaScript ecosystem, I think it becomes even more important to gain at
least some level of compatibility with the system.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1397?email_source=notifications&email_token=AAW4RGVRC67Y4NNQ6E4DKODPVQRRBA5CNFSM4GL5G5WKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVO7AXI#issuecomment-492695645>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAW4RGXOYR5T2RQX27X6XT3PVQRRBANCNFSM4GL5G5WA>
.
|
Deno clearly doesn't want to inherit the existing Node.js ecosystem and be encumbered with it. There are some things that can be done to make things easier, but Deno is Deno. If people want a better Node.js then they should use Node.js v12. Deno has different goals and objectives as Node.js and adoption, at this stage, is not a key goal. As it has been mentioned import-maps is the almost official way of package mapping on the web, therefore is being adopted by Deno. |
Hi, importmap is supported by deno, but how can we use it to leverage the existing packages? |
@kitsonk disregarding the largest wealth of open source projects and calling it a hindrance is not at all wise, 10 years of active contribution that makes these collection the life blood of node and you choose to leave it all on the table and not make it a top priority, this interoperability would greatly benefit developers from the get go of v1 deno, it would do loads of good for deno the product of the next decade. im sure if not the core team the community would make this possible very shortly |
@dheeraj-br When Node.js was started, it disregarded the largest repo of open source projects-- Perl's 20,000 CPAN modules and made no attempt to be compatible with it. Today Perl has 40,000 CPAN modules and Node.js has 1,135,000 modules despite having to start a module repository from scratch. |
But what is the upside of starting the module ecosystem from scratch? Is it
having all codebases using typescript? Would the compatibility prevent deno
from providing some features or optimizations?
…On Thu, Nov 21, 2019 at 4:09 PM Mark Stosberg ***@***.***> wrote:
@dheeraj-br <https://github.com/dheeraj-br> When Node.js was started, it
disregarded the largest repo of open source projects-- Perl's 20,000 CPAN
modules and made no attempt to be compatible with it.
Today Perl has 40,000 CPAN modules and Node.js has 1,135,000 modules
despite having to start a module repository from scratch.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1397?email_source=notifications&email_token=ABHLQMDFBOH4PXA6OG2ICDLQU2QDJA5CNFSM4GL5G5WKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2RLOQ#issuecomment-557127098>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHLQMCONAUK4GD3XWF7PNTQU2QDJANCNFSM4GL5G5WA>
.
--
Biel Simon Rojas
[email protected]
<[email protected]>
|
I don't know what the right decision is for Eventually another project comes along that drops all the old baggage. It is clearly simpler and more pleasant to use. New users flock to the new choice because they don't care about backwards compatibility. More time passes and the new users outnumber the old users. The backward-compatibility that was once seen as a feature is now seen as legacy technical debt. Apache used to rule as the dominant web server, adding and more and more features, plugins, and an "MPM" layer to support different ways to serve web pages. Nginx learned from the features and mistakes of Apache, completely dropping backwards compatibility with Apache config files, creating a new simpler way to serve web pages. Apache tried to respond to by adding yet more complexity, while maintaining backwards compatibility. Nginx's market share took off like a rocket at Apache's expense. The question for Deno is whether it can disrupt Node.js like that, or whether it's strives to do well in a niche and not compete directly. If Deno were to be highly compatible, that it might be seen as only incrementally better. If so, then why switch? |
As a small update to the situation, std/node now provides a way to create a Since it is part of the standard library, it is independent from the Deno binary. The general idea is to promote use of ES Module and Deno APIs, while people still can import from Node.js modules if no alternatives are available. |
wouldn't harm to have the compatibility since its a case of adding more polyfils and would not affect the Deno architecture in any way, in fact it would be detrimental to the switching over from node to deno only thing that would keep me stuck on nodejs is the wealth of packages. i wouldn't switch to deno even with its javascript(for prototyping) and typescript (for scaling), wasm, its speed, es modules, the developer user experience etc. i can't switch because im chained to the node ecosystem. The way you suggest would most definitely restrict deno to a niche market in the shadow of well established node, im staying with node and keeping my 1,135,000+ packages. |
@kevinkassimo Hi, I am not sure if I have misunderstood, I am not very familiar with node and coming straight to deno. I have a common JS module
The result is:
It does not matter if I add the '.js' or not. Is this a bug, or am I doing something wrong? Thanks. |
@David-Else can you print out your |
@kevinkassimo when I do
This is the name of the file that is running the
./eslint-recommended.js
|
@David-Else Figured it out. This is because our CJS loader will try to Try I'll see if I could make the loader throw an error that is more relatable with |
@kevinkassimo Thanks, it worked! I hope someone can add an appropriate error message for this situation, I think it is important. Deno often suggests the |
How am I to find drivers to "talk" to Azure Cosmos DB or MongoDB or MySQL or MSSQL? If there's no database story with Deno, what can we realistically do server side? I need these drivers for databases. EDIT: My next step was to create an auth service agains Azure Cosmos DB when I ran into the fact I don't see any database libs out there really. I see this one but it does me no good: https://deno.land/x/mysql/ I guess it's still early days and I'll have to wait to use Deno for more than toying around or write something myself. |
There are mysql, dynamodb, postgres libraries already (I've tried the last two and they worked for me). It looks like there is a javascript (browser) sdk for azure which has a cosmodb directory... https://github.com/Azure/azure-sdk-for-js it's possible it will "just work" 😬 |
@hayd so you think just copy /src from here https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cosmosdb/cosmos into my project and follow the examples it it might "just work"? |
@hayd I tried to copy the cosmos directory over and work through the issues. Deno errors have a lot to be desired. For example: > deno --allow-net main.ts
NOTE: in the above project directory, main.ts is in root and a /cosmos directory is there to contain the files from the cosmos sdk. And this is such a big library, it will take a lot of time to go through the lib... uhh Second thought, might be easier for me just to wrap up MySQL or PostgreSQL into a container and wire up my Web App to Db container inside azure instead of using integrated Cosmos... |
I made an example repo that allows someone to convert
npm
modules for use with deno.https://github.com/reggi/node-to-deno
Not sure if anyone is interested or if this has been done before.
Is there any discussion for making polyfills
node -> deno
anddeno -> node
for standard lib? That's the next chunk needed to make some node modules work with deno.Is there any discussion about something like a mixture of what I built and https://unpkg.com? A whole CDN registry that has npm modules ready to use with deno?
The text was updated successfully, but these errors were encountered: