I am trying to create an npm module. In my src directory I have index.ios.js and index.android.js. In my entry key of package.json I have index.js. This is resulting in import errors. Is it possible to use platform specific extensions in npm module?
Here is my package - https://github.com/Noitidart/react-native-buttonex
In summary - What should entry be if src/index.android.js src/index.ios.js
Related
i want to use one vue sfc in another project. I have project1 with componet and make npm package, publish it to own gitlab package registry and use it via npm install. Everything work great, but...
The sfc Foo.vue in FooProject import another one, like: import ChildFooComponent from '#/components/ChildFooComponent.vue'. if i run (npm run dev or build) FooProject, evrything works. But if i make npm package via npm publish and want to use it at BarProject as import Foo from '#FooProject/src/Foo' (FooProject with Foo already is in node_modules)
the build say: cant find module '#/components/ChildFooComponent.vue' in Foo. when i change the import in FooProject in Foo.vue to import FooChildComponent from './components/ChildFooComponent.vue' then every thing works as i expected. i know that # poitns to src folder of actual project, in this case src folder of BarProject, right? but how to tell npm that if # is in FooProject use the src folder of FooProject not BarProject?
I have a nx monorepository, where I have a webcomponent which are boundled as a js file.
Presently, reuse of code works with including the webcomponent js file in the index.html. I would like to export this as an npm package at my feed in azure DevOps so other developers in my company can reuse this code by the npm i command upon the package.
How do I move from the present solution to a npm package using nx. Do I need to make a new nx project for creating such an npm package, since it requires a package.json or is there a way I can use nx to create npm from a js file?
In my project, we use react-native-azure-ad plugin. The problem is, this plugin at npm is outdated and use a deprecated way of accessing webview which has already been extracted from react-native to react-native-webview.
When I browsed the github page and observe the source code there, it looks like the code on the github is already updated to use react-native-webview, which lead me to believe that the npm package is not updated by the author to follow the github version.
There's only one way to fix this, that is by downloading the module directly from github and import it manually. The problem is, I only know how to import the module from installing by npm.
Currently, this is the basic folder structure:
Root
- node_modules
- src --> the app source code
I want to put the module like this:
Root
- node_modules
- node_updates
- react-native-azure-ad
- src
And I want to still be able to import it like this:
import {ReactNativeAD, ADLoginView} from 'react-native-azure-ad'
Of course I will remove the react-native-azure-ad from package.json and reinstall the node_modules afresh beforehand.
Is this possible?
I'm hoping that I don't have to rely on relative path like:
import {ReactNativeAD, ADLoginView} from '../../../node_updates/react-native-azure-ad'
I have seen some answers like this, but this requires me to use relative path to import.
using npm:
npm install <git-host>:<git-user>/<repo-name>
or
npm install <git repo url>
when using public git repo.
using yarn:
yarn add <git remote url>
or
yarn add <git remote url>#<branch/commit/tag> when you need specific branch or etc.
I use npm in my client side development.
I use ES6 and I import modules to mapApp.js file from library that I installed in node_modules folder with help of npm tool.
Here is how I import module to mapApp.js file:
import GML from 'ol/format/GML';
Where is 'ol/format/GML' is relative path to node_modules folder.
At some point I create my own module(in config.js file) outside of node_modules folder and I need to import it to mapApp.js file.
Here is picture of project archeticture:
My question is how can I config npm to make search for imports not only in node_modules folder but,
also in specific folder outside of node_modules?
Is there a way using npm to treat a file in the project as a node-module without linking it and it having it's own package.json?
Ideally I could just have a sub-module definition within my main app package.json and be able to install things to a specific module that way.
Here's an example
/app
/index.js
/file.js
/action.js
What I'd like
npm set-as-module ./action.js "action"
Then within any file in my project I can call
var action = require("action")
Then when I want to install specific dependancies for action I could do this
npm install underscore --save --sub=action
This this kind of feature exist within NPM? Anything close to it?
This would offer the following perks
Easy to branch out or publish into full module
ability to require with module string instead of path
I created something to do this
https://github.com/reggi/npm-link-file
npm install npm-link-file -g
npm-link-file ./action.js "action"
It does not handle linked dependancies.