I'm working on an application that has build dependencies on react and react-dom. Is it possible to use rollup to bundle these dependencies separately?
Outputs:
react.js <-- react library
react-dom.js <-- react dom library that imports react.js above
app.js <-- my application code
Related
I have installed msw using package.json entry in my react typescript project. And appropriately invoking msw worker start but I constantly get the error
**getWorkerInstance.ts:85 Uncaught (in promise) Error: [MSW] Failed to register the Service Worker:
Failed to register a ServiceWorker for scope ('http://localhost:3000/') with script ('http://localhost:3000/mockServiceWorker.js'): The script has an unsupported MIME type ('text/html').
at getWorkerInstance (getWorkerInstance.ts:85:1) at async startWorkerInstance (createStartHandler.ts:31:1) at async SetupWorkerApi.start (setupWorker.ts:188:1)***
**
Can anyone provide an example source code of how msw works with react typescript ? I got a native react project but that worked? Is msw not supported with React typescript?
Can anyone provide an example source code of how msw works with react typescript ? I got a native react project but that worked? Is msw not supported with React typescript?
Overview:
I created a NPM dependency react-native-ultimate-modal-picker and it relies on a few other dependencies.
Expected Behavior:
React should be installed because it's installed in the fresh react project.
Error:
ReferenceError: Can't find variable: React
What I've tried
The components in my NPM Package react-native-ultimate-modal-picker, all of the components have react imported. Link to Code
Installed react and react-native as peerDependencies for my NPM Package react-native-ultimate-modal-picker
So what am I missing here?
Try importing react like import React from 'react' and not import * as React from 'react' at the beginning of every module.
I am working on a React Native app which includes a self-written React Native module included as local NPM module.
My NPM module as well as the React Native app including that NPM module, depend on React and React Native.
As a result, metro bundler is complaining about naming collision since the NPM packages are included twice.
To avoid that, I have added React and React Native in the self-written NPM module as peer dependencies.
However, if I do that, metro bundler is complaining that it is unable to resolve module "react" / Module "react" does not exist in the Haste module map of my self-written NPM package.
Any suggestions?
It sounds like you just need to move react-native (and maybe react) from the dependencies of your self-written module's package.json to peerDependencies instead.
Make sure react and react-native are in the dependencies of your app’s package.json and you should be good to go.
If your module needs react-native outside the context of an app, for tests or building, you can add it to devDependencies with no risk that it’ll be installed again into your host app.
peerDependencies are a way to represent that your module needs another module to be installed alongside it, but it's the responsibility of the host application to have the hard dependency and specify the version it wants.
I am trying to use a component via NPM called React-TimeAgo. I have managed to install it via NPM and have Webpack integrated with Rails to generate a webpack bundle our of my node_modules.
This is all working fine when I import a Javascript library (like bootstrap) but not working with this React TimeAgo component. I think its the way I am trying to import from Webpack.
In my index.js I have:
window.bs = require('react-bootstrap') <- this is working
window.timeago = require('react-timeago') <- I don't think this is
And then in the view I have:
<%= react_component "TimeAgo", {date: 'Aug 29, 2014'} %>
But I get a runtime error saying the component TimeAgo could not be found.
What am I missing? Any assistance greatly appreciated.
I'm learning Dart and its dependency manager pub and am having a tough time seeing the "forest through the trees" here.
Say I want to use Polymer.dart in my project. So, in my project root, I create the following pubspec.yaml:
name: test_dart
description: A sample web application
dependencies:
browser: any
polymer: ">=0.9.0 <0.10.0"
I then run pub get, which goes to the pub repo and fetches the browser and polymer dependencies that I've specified. It then creates a packages directory in my project root, which now means I have a project that looks like:
MyDartProject/
pubspec.yaml
myapp.dart
packages/
browser/
...
...all the packages that ship with Polymer
Now I start coding my Dart web app (myapp.dart), which will references various Polymer and browser types/functions/etc. in its source code.
When I'm all done, I want to create a JavaScript file called myapp.js.
According to the dart2js docs, I need to run something like:
dart2js --out=myapp.js --package-root=??? myapp.dart
How do I include all the browser & polymer packages on the buildpath?
There is a "pub build" option now.
http://pub.dartlang.org/doc/pub-build.html
Use pub build when you’re ready to deploy your web app. When you run
pub build, it generates the assets for the current package and all of
its dependencies, putting them into a new directory named build.
$ cd ~/dart/helloworld
$ pub build
Building helloworld......
Built 5 files!
If the build directory already exists, pub build deletes it and then creates it again.
That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose "pub build"
EDIT: You should also see the links in zoechi's answer.
If you run dart2js from your MyDartProject directory you don't have to provide --package-root parameter.
An alternative way is running pub build. If you use Polymer you need to add a transformers section.
see also
How to deploy a Dart Polymer app to Javascript using dart2js
How do I pass multiple entry_points to polymer transformer in pubspec.yaml?