-
Notifications
You must be signed in to change notification settings - Fork 247
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
ES6 import fails #607
Comments
Same with #593, can't work with https://vitejs.dev/, which uses esbuild. We should prioritize es6 module in 2021! |
Any timeline on this, this is a blocker for us to do some interesting stuff. |
It seems these 2 issues are unrelated to this next question but I was wondering if its possible to get the ES6 version of this library to work similar to near-cli, so transactions can be signed+submitted to mainnet if fed a seedphrase/accesskey in a non-browser app. |
@MaximusHaximus , we need some help from a JS person here :) Is it something that we can fix and how? |
@volovyk-s Yes, we can publish an both an esm module version and the currently commonjs version. We'd keep publishing the standard JS version to I think that should be all we need to do :). Anyone wanting to import ESM modules would just import from Check out this handy-dandy example changset from the Sentry repo where they added an ESM build to their existing pipeline: Also related to 'new shiny import capabilities', It's also worth reading about package.json |
marvelous |
Any status update on this, it would be nice to be able to use near-api-js from serverless environments (AWS/cloudflare) to do things like call contracts. |
@vans163 I will try to work on it this month. If it's urgent - please, create a PR. |
Not urgent. Thanks. |
Hello guys, thats critical bug for me, I don't know how to add near-api-js to my application. I tried @originjs/vite-plugin-commonjs, but it doesn't work. Then I tried to add in packages.json @volovyk-s branch #esm-artifacts, and |
@tonborzenko please, use import without the |
I got this to work with CJS inside serverless with some fixes (ESM does not work). This only supports webpack and you need webpack.config.js
Buffer and process plugins. I think this line needs revising because this also crashes inside browsers with Line 161 in fd6d643
Perhaps check here first is You might also need |
Having the same problem with import in Vite project.
|
Created a repository which you can use as an example until its fixed |
@VolanDeVovan Example you've created is outdated now. If possible can you update it with latest changes ? |
Adding a an alias to the unminified file seems to work
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'near-api-js': 'near-api-js/dist/near-api-js.js'
}
}
}) |
Gentle ping on this - adding |
I've done some work to resolve the outstanding issues on my end to allow for the
Edit: it crossed my mind to try this - but no luck
|
Hi @jessupjn, I actually have a PR to address this. It's currently in the review phase and is part of the upcoming refactor which will break up Please feel free to take a look and leave any feedback or questions you might have. There is an |
Great - I'll give it a whirl when I find some time! Is there an ETA on this PR going out? |
@jessupjn I'm optimistic that we can have it published by the end of March, we should have much better availability coming up. If you have more questions about this work I'd strongly encourage you to leave comments on that PR or on #1056, which is a prerequisite. The more discussion and questions going on there will help drive home the point of how important these improvements are and hopefully get it out to developers sooner 😄 |
@jessupjn can you please check this comment #1072 (comment) you might be able to resolve the issues with Follow the links in that comment for better understanding. This is a demo of wallet-selector with |
The issue is fixed now as large near-api-js was broken down into multiple number of smaller packages as (@near-js/*) . You can find the packages at https://www.npmjs.com/search?q=%40near-js and use es6 imports as:
|
near-cli uses this package but with require.
On a platform with no require. (but ES6 import)
Using it with import leads to a slew of issues (for use in a regular JS app without browser).
The text was updated successfully, but these errors were encountered: