-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
"yarn workspace" commands don't work #101
Comments
I am also experiencing this issue. |
Weird, we have a test for this case: https://github.com/martpie/next-transpile-modules/blob/master/src/__tests__/__apps__/yarn-workspaces/app/pages/test-local-typescript-module.tsx Maybe I should try to add a react component as well Edit: see #101 (comment) |
Here's the error I'm getting on my project, seems related to @aswbot I however am getting this called on interfaces, not just types. I've been attempting to resolve this for a few days with no luck, but this is a new issue for me. This was working without issue for a long time, then suddenly stopped working (after updating).
|
It looks there is an issue with some TS features transpilation, I will try to have a look as soon as I can, but I have a lot on my plate right now. I recommend you rollback your Next.js version for now (or submit a PR if you really cannot wait) :) |
@aswbot Can you try using |
@martpie Thanks for the test and issue hunting I actually found the reason why it was not transpiling correctly. Firstly I tried what you proposed but still had no luck. I then thought it had something to do with scoped packages so I tried making the components just The real reason was my tsconfig.json which had {
"baseUrl": "packages",
"paths": {
"@app/components": ["components/src/"]
}
} I removed baseUrl and paths for ready to be transpiled local packages and it started working. |
I have no clue why this made the difference for me, but using your comment @aswbot I was able to get mine working too. I haven't been able to pinpoint what changed between these repos, but simply changing my |
Thank you guys for the investigation, I will try to check what is going wrong exactly |
I've got hit too, created a sample repo based on latest with-yarn-workspace examples. You can have a look if it helps: Thanks for your work on this, really appreciate!
|
To anyone with this issue:
|
Hey @martpie... Edit: I tried few older versions on this P/R belgattitude/next-transpile-ts-workspace#4 to be sure, but I'll probably need to tune the typescript/workspace setup. I'm also investigating those issues that would avoid transpilation: |
@martpie My bad it looks everything works for me (at least onlinux), was just stupid and forgot to transpile foo. I'll make a p/r in nextjs example for those who got stuck like me. Thanks a lot anyway. |
I made the mistake of not updating the usage when updating from a much older version (2.3). Worth checking in case this is anyone else's issue.
|
Our team was running into this issue recently as well. If your module.exports = withTM({
transpileModules: ['@alias/core']
}); This would point to a folder in our repo that had a module.exports = withTM({
transpileModules: ['core/*']
}); After doing so and running our dev environment, things seemed to start working as expected again. Not sure what changed. In our repo we use yarn workspaces, we have a number of folders with package.json files and whatnot, though, we don't have everything stored in the same folder, maybe that's part of this issue? 🤷 |
I will try to investigate this issue this week guys. I may have time to land a hotfix before #132 lands |
Should hopefully be fixed in #132 if anyone has the courage to test the branch 😄 (careful it is unstable) Will leave open until I have confirmation. |
@martpie still exists, manually adding |
With v6? |
@martpie Yes, it doesn't recognise the subpackage, doing manual path mapping just solves it. |
Have you followed all the FAQ steps and checked v5/v6 changes and setup indications? |
@martpie If from that you mean have |
Do you have a reproduction/some code I could look at? |
@martpie Hi, not yet. I will codesandbox tomorrow, for quick here is yarn worksapce directory structure
and error log: Loaded env from /path/to/project/apps/web/.env.local
Loaded env from /path/to/project/apps/web/.env
info - Using external babel configuration from /path/to/project/apps/web/babel.config.js
info - Creating an optimized production build
Failed to compile.
/path/to/project/packages/ui-library/src/index.ts 7:7
Module parse failed: Unexpected token (7:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| export { styled, createStyledProps } from './styled';
> export type { StyledProps, ResponsiveProps, CSSModule, Tag } from './styled';
| export { styled as _styled, css } from './styled.config';
|
> Build error occurred
Error: > Build failed because of webpack errors
at build (/path/to/project/node_modules/next/dist/build/index.js:15:918)
shobhitsharma@Shobhits-MacBook-Pro web % This error only resolves when I change: |
Workspace in root package.json:
Here is package.json of components:
|
Why did you enable |
I just tried removing Actually it all happened after adding the dependencies - Do you think, the error has something to do with any one of these dependencies? |
If you manage to identify which combination causes the issue, I'll be able to dive in and see what causes the issue, but this is a different issue than this one |
@martpie As suggested by you, I removed all these plugins, deleted my node_modules package and started adding these plugins one by one, and this time, I don't know how everything worked out. Now I am able to run the app from root folder as well as from the nextjs folder. Don't know where I messed up, but now everything is working fine. Thank you so much for all your support. |
|
const CWD = process.cwd(); |
I imagine in a yarn workspace
command, process.cwd()
resolves to the root of the workspaces, but we want it to be resolved to the root of the Next.js application.
If anyone knows a quick way to fix this, feel free to post here a hint or submit a PR.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi @martpie, I am trying to transpile several packages from Here is my configuration:
node v15.13.0 My const withTM = require('next-transpile-modules')([
'@polkadot/api',
'@polkadot/api-derive',
'@polkadot/extension-dapp',
'@polkadot/hw-ledger',
'@polkadot/hw-ledger-transports',
'@polkadot/keyring',
'@polkadot/metadata',
'@polkadot/networks',
'@polkadot/rpc-core',
'@polkadot/rpc-core',
'@polkadot/rpc-provider',
'@polkadot/ts',
'@polkadot/types',
'@polkadot/types-known',
'@polkadot/ui-keyring',
'@polkadot/ui-settings',
'@polkadot/util',
'@polkadot/util-crypto',
'@polkadot/wasm-crypto',
'@polkadot/x-fetch',
'@polkadot/x-global',
'@polkadot/x-rxjs',
'@polkadot/x-ws'
]);
module.exports = withTM({
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
issuer: {
test: /\.(js|ts)x?$/
},
use: ['@svgr/webpack']
});
return config;
}
}); I aliased
"main": "node.js",
...
"exports": {
".": {
"require": "./index.cjs", // Had to add these two lines, otherwise path error occurs
"default": "./index.js", // Had to add these two lines, otherwise path error occurs
"browser": {
"require": "./browser.cjs",
"default": "./browser.js"
},
"node": {
"require": "./node.cjs",
"default": "./node.js"
},
"react-native": {
"require": "./react-native.cjs",
"default": "./react-native.js"
}
} Any clue where I might be wrong? |
I haven't had time to investigate this issue too much yet |
Note however that they do not use scoped variables there. |
@darwin403 I haven't had problem with scoped packages and yarn or even yarn-3.0.0-rc.2 (not yet pnp).
I think you should be able to upgrade to latest NTM by
See the latest NTM doc about it. PS:
|
@belgattitude Thanks. Creating a |
@martpie not sure if this is exactly what is needed - but the yarn API provides relativeCwd and workspacesCwds |
Thank you @dweste01, will look into it |
Getting the same error as above: But only when I deploy my monorepo via Vercel. Everything works as expected running locally 🤔 |
@owensco probably unrelated. Make sure your transpiled dependencies are NOT |
@martpie thanks for the reply. I was able to resolve the error by modifying the path of the shared package in from: I don't think this is an actual solve as none of the examples require this. It's also lead to new |
cf. #101 (comment) The problem is explained here, I just don't know how to solve it. |
@martpie that did it! Thank you so much! For anyone running into this issue when deploying to Vercel, make sure you update your build & deploy settings to use yarn and not npm 🤦♂️ |
I think it would sound perfectly reasonable to pass a directory as an option to This is what it could look like as an option: /* next.config.js */
const withTM = require('next-transpile-modules')(['some-module'], {
dir: __dirname
}) /* next.config.mjs */
import nextTranspileModules from 'next-transpile-modules'
import { pathToFileURL } = from 'url'
const withTM = nextTranspileModules(['some-module'], {
dir: fileURLToPath(new URL('.', import.meta.url))
}) |
Hello.
Are you trying to transpile a local package or an npm package?
Local package
Describe the bug
To Reproduce
Expected behavior
It should work out of the box afaik, no babel configuration as Next comes with TypeScript support.
It is weird but removing the types does work. It only complains about type annotations/declarations. 🤔
Any ideas?
Setup
next-transpile-modules
version: 4.0.2npm
/yarn
version: Yarn 1.22.4The text was updated successfully, but these errors were encountered: