Comments (8)
Adding the signature option like this: yalc push --sig
worked for me.
from yalc.
I have the same issue and would like to see this solved. However sounds like a problem within the apps context and not yalc. What worked for me:
In my package:
npm run build
yalc publish --push --no-scripts
In create react app
rm -rf node_modules/.cache/
npm run start
Important note: Consider I've previously already added the package with yalc (yalc add ..
)
I've also tested in a nextjs app and I ended up also doing rm -rf .next/
from yalc.
Yall need something like this in your webpack/nextjs config. Also don't forget to use next-transpile-modules with nextjs and transpile your node modules
/**
* Make HMR work in all ./node_modules/@headout/ libraries
* Needed after the next.js 12 upgrade along with transpiling the @headout libraries
*/
config.snapshot = {
...(config.snapshot ?? {}),
managedPaths: [
/^(.+?[\\/]node_modules[\\/])(?!@headout)/,
],
};
// Replace the '**/node_modules/**' with a regex that excludes node_modules except @headout
config.watchOptions = {
...(config.watchOptions ?? {}),
ignored: [
'**/.git/**',
'**/node_modules/!(@headout)**',
'**/.next/**',
],
};
from yalc.
Thanks so much regalstreak for this config, it fixed my problems. For future viewers of this issue, here is my slightly modified solution for using create-react-app
and yalc
:
- Install
react-app-rewired
to modify the webpack config.npm install --save-dev react-app-rewired # or yarn install -D react-app-rewired
- In your
package.json
, change the scripts to usereact-app-rewired
instead ofreact-scripts
."scripts": { "build": "react-app-rewired build", "eject": "react-app-rewired eject", "start": "react-app-rewired start", "test": "react-app-rewired test" },
- Create a file in your root dir (next to
package.json
) namedconfig-overrides.js
with the following code (based on regalstreak's answer above). Replace"YOUR-MODULE-NAME-HERE"
with the name of your module.const moduleName = "YOUR-MODULE-NAME-HERE"; // `node_modules/.cache` makes it difficult to use yalc to update local // libraries and use create-react-app's hotloading. This override fixes that // issue. // // Source: https://github.com/wclr/yalc/issues/195 module.exports = function override(config) { const managedPaths = config.snapshot?.managedPaths ?? []; managedPaths.push( new RegExp(`^(.+?[\\\\/]node_modules[\\\\/])(?!${moduleName})`) ); config.snapshot = { ...(config.snapshot ?? {}), managedPaths }; const ignored = config.watchOptions?.ignored ?? []; ignored.push(`**/node_modules/!(${moduleName})**`); config.watchOptions = { ...(config.watchOptions ?? {}), ignored }; return config; };
Now, any time you update your source module, you can run yalc publish --push
and your code will be properly loaded in the dependent module(s). It even works when npm start
is running with create-react-app
-- your changes will be hotloaded.
from yalc.
maybe create react app caches something, I don't know how it works, maybe it checks for lock files for changes. If you use yarn try do yarn upgrade pkg
after updating yalc'ed package pkg
and see if CRA graps this update.
from yalc.
Adding the signature option like this:
yalc push --sig
worked for me.
This is the solution, other than the above hacks.
Thanks @filipsvensson
from yalc.
I have been able to get Hot Module Reloading working by using yalc link
instead of yalc add
. I'm interested to see if --sig
works for me, since supposedly sig
is true by default.
UPDATE: Using --sig
on the publish/push command did work for me! With --sig
I was able to use yalc add
instead of yalc link
and HMR was working. It seemed a little slower than using yalc link
though. Thanks for the tip!
from yalc.
I'm using yalc for a TypeScript shared library, consumed by a CRA app. The HML reloading does work for me (with or without --sig
) but the push
takes a very long time (approx 10s for any change, even a single char).
The shared library is bundled with rollup. I use rollup --watch
to recompile on change:
"rollup:dev": "npm run clean && npx rollup --config rollup.config.js --watch --watch.onEnd=\"yalc push --sig --changed\""
Is there anything I should change in this setup, to speed up things?
Thanks! :)
from yalc.
Related Issues (20)
- `yalc link` broken after adding/removing packages
- Is there a way to remove the published packages in the StoreMainDir ? HOT 2
- How to pass aditional args to npm update on pushing
- Is this project still active? HOT 13
- Dependencies not being installed when using `--link` HOT 1
- package version dependent? HOT 1
- yalc link across 2 monorepos not working HOT 2
- Resolve dependencies of a package with a specific value
- Import statements not resolving when using `yalc link`
- Importing `axios` is not executed crrectly
- Invalid "file:.yalc/<package name>" from the root project HOT 1
- Support push to remote and pull from local
- [Bug] I need to re-add the dependency every time it updates after I re-push it HOT 1
- Yalc add shows "Could not find package" HOT 1
- [BUG] yalc add does not include the same files as npm pack & publish HOT 1
- Allow specifying store-folder as an environment variable.
- How to render yalc add dynamically HOT 1
- How do you use `yalc` and `npm`/`yarn` in the same package?
- "yalc" is not recognized (Windows + Yarn) HOT 1
- It doesn't work..
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yalc.