Skip to content
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

fix: Fix imports from near-api-js #765

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

kujtimprenkuSQA
Copy link
Contributor

@kujtimprenkuSQA kujtimprenkuSQA commented Apr 6, 2023

Description

This PR is about fixing the way we import modules from near-api-js.

In our packages we import code from NAJ in this way:

import { providers, utils } from "near-api-js";

Although this is not necessarily “wrong” there are no linting or build errors and when our packages are installed via npm/yarn everything seems to work just fine.

The problem shows up when the CDN link is used in a dApp to import our packages.

From more investigation, it was found that NAJ does not export named modules at the top level for accountCreator, providers, utils, transactions, validators, multisig somewhere in the code everything is first imported as an alias and then exported:

import * as providers from './providers';
import * as utils from './utils';
export { providers, utils };

So in the end the browser is not recognizing these exported modules as named modules when the CDN links are used.

This PR changes the way we import modules from near-api-js and to import everything like:

import * as nearAPI from "near-api-js";

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Type of change.

  • FIX - a PR of this type patches a bug.
  • FEATURE - a PR of this type introduces a new feature.
  • BUILD - a PR of this type introduces build changes.
  • CI - a PR of this type introduces CI changes.
  • DOCS - a PR of this type introduces DOCS improvement.
  • STYLE - a PR of this type introduces style changes.
  • REFACTOR - a PR of this type introduces refactoring.
  • PERFORMANCE - a PR of this type introduces performance changes.
  • TEST - a PR of this type adds more tests.
  • CHORE - a PR introduces other changes than the specified above.

@github-actions github-actions bot changed the title Fix imports from near-api-js fix: Fix imports from near-api-js Apr 6, 2023
@kujtimprenkuSQA kujtimprenkuSQA merged commit 7578f2f into dev Apr 6, 2023
@kujtimprenkuSQA kujtimprenkuSQA deleted the SQC-504/fix-default-and-named-imports-form-naj branch April 6, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants