question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module Namespacing Support for Packages

See original GitHub issue

Summary

When installing a package that uses module namespacing (export * as {moduleName} from './{moduleName}), Expo’s default configuration throws an error when compiling for web and iOS. This is an important tool for structuring TypeScript code, so I’d expect it to work out of the box.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

iOS, Web

SDK Version (managed workflow only)

4.5.2

Environment

MacOS, Node v14.15.5.

Reproducible demo or steps to reproduce from a blank project

https://snack.expo.io/kSlfJiSnR

Steps to reproduce:

  • npm install @dfinity/agent
  • Somewhere in the code - import { HttpAgent } from "@dfinity/agent";

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
krpeacockcommented, Jun 11, 2021

Ah right, that’s the domain-specific stuff. I’ll unignore that folder and push it up for reproduction to spare you from needing to install our SDK. You won’t end up with a fully working example, but the frontend should compile

0reactions
byCedriccommented, Jun 11, 2021

Yes, that’s also possible! I’m not sure how Snack would react, but we can always find a solution for that later.

  • With normal npm modules, you should be able to define main file as entrypoint (defaults to index.js). This could contain plain Common JS code.
  • With tools like Rollup and Webpack, you can define a module entrypoint. (although this isn’t an “official” spec, it’s still in proposal state). This could contain the ESM code.
  • With React Native, you can define a react-native entry point. (couldn’t find the docs for this, but you can see it there in action). This could contain the Common JS code, with some polyfills included.

All of these can be defined in the package.json, and there are a few like typings for TS. This guide might help making sense of some of these.

Other companies using Web3 opted for a separate React Native package. This is also fine and worth taking a look at, e.g. Magic Link

Read more comments on GitHub >

github_iconTop Results From Across the Web

Packaging namespace packages
Namespace packages allow you to split the sub-packages and modules within a single package across multiple, separate distribution packages (referred to as ...
Read more >
Documentation - Namespaces and Modules - TypeScript
This post outlines the various ways to organize your code using modules and namespaces in TypeScript. We'll also go over some advanced topics...
Read more >
support namespace packing #167 - python-poetry ... - GitHub
It seems that you are looking for poetry options to control the distribution name independently of the package names. If you have trouble...
Read more >
python namespaces vs packages: making a ... - Stack Overflow
Now, because pypackage is a setuptools namespace package you have a different problem; namespace packages are there for multiple separate ...
Read more >
Ruby Cookbook: Modules and Namespaces - O'Reilly
A Ruby module is nothing more than a grouping of objects under a single name. The objects may be constants, methods, classes, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found