问题标签 [nx.dev]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - 支持 nx.dev 中的可选链接和无效操作
在第一步我添加
"typescript": "~3.7.5"
然后我添加
"prettier": "1.19.1"
它应该已经足够了,但我仍然收到这个错误:
'optionalChaining' 当前未启用
所以我尝试添加
"react-scripts": "3.3.0"
和
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3"
"@babel/plugin-proposal-optional-chaining": "^7.8.3"
但问题仍然存在,我是在我的普通CRA应用程序中完成的,但我不知道如何更改nx.dev配置中的babel预设列表。
nx.dev - Nx.dev 没有显示我新创建的插件
我正在尝试理解和使用nx.dev 开发工具 基本上我现在想做的是创建一个自定义插件。
所以我首先安装了@nrwl/nx-plugin 插件,它允许构建自定义插件。然后我使用以下命令创建了一个测试插件:
完成后,我构建了插件:
然后我发布到 npm(当然是我的本地 npm 存储库,通过Verdaccio托管)
完成后,我安装了全新的插件,就像您使用任何其他 nx 插件一样:
请注意,这@webtest
是我的 nx.dev 工作区的名称
命令成功,但是当我这样做时:
我在已安装的插件列表中没有看到它。我得到的是:
我会期待@webtest/my-plugin
在那里。我在这里想念什么?自定义插件是否应该出现在已安装插件列表中?
javascript - nx.dev 中的构建前和构建后步骤
我正在使用nx.dev构建和测试 Web 应用程序。包含用于构建和测试应用程序的workspace.json
脚本,但是构建阶段仍需要对某些文件进行预处理。
有没有办法添加预构建步骤(即指定外部 bash 脚本或 JavaScript 代码)?
在线文档没有提到 https://nx.dev/react/cli/build
javascript - Apollo/Express 服务器在 nx.dev 环境中不工作
我正在尝试使用 apollo-server-express 创建一个简单的 graphql 后端。
在 expressJS 应用程序(Github repo)中执行此操作按预期工作:
执行查询
在 localhost:4000/graphqlresult
按预期返回。
解析器
现在我想在 nx.dev 环境(Github repo)中使用这个 expressJS 后端。我在这里设置了相同的东西,但是在 graphQL 操场上运行服务器并执行查询会返回null
.
我不明白出了什么问题。
这是我的结构:
main.ts
结构体
解析器.js
类型.js
graphql/search/search.graphql
graphql/search/search.resolvers.js
javascript - 如何清除 Nx 缓存
我有一个 Nx monorepo ( https://nx.dev )。它有一个带有 Nx 缓存 ( ./node_modules/.cache/nx/
) 的文件夹。它现在的大小超过 3GB。
是否有清除此缓存的命令?
nrwl-nx - 如何使用 NX CLI 将命令转发到运行命令?
鉴于我在 angular.json 中有使用无服务器 CLI 定义各种命令的条目(例如)
如何通过减少重复并将其合并到一个条目中来改进这一点,以便我可以转发命令?
EG是这样的:
然后用 nx run my-app:sls MYCOMMAND (EG 'deploy' 或 'remove') 调用它?不幸的是,上述方法不起作用,但很想知道这是否可能。
reactjs - 在 Nx 和 React 中使用组件级块
在 Nx 中有一种方法可以在 React 应用程序中拆分组件级别的块。如果是,请分享是否有人这样做。
目前,我看到的唯一选项是 commonChunk 和 namedChunks,但它们没有达到目的。添加动态导入不会生成块。我尝试使用 React.lazy 和 React Loadable 但还没有成功。我正在使用 nx web 构建执行程序。
javascript - Error: 'jsxs' is not exported by node_modules/react/jsx-runtime.js on building publishable react:lib
Current Behavior I have created a sample nx.dev react application with a publishable react library (ui-public). When I try to build the publishable react library it throws below error
Repo where is the build is failing: https://github.com/nitesr/trynxdev
nx run ui-public:build Bundling ui-public... Error when using sourcemap for reporting an error: Can't resolve original location of error. Error during bundle: Error: 'jsxs' is not exported by node_modules/react/jsx-runtime.js Bundle failed: ui-public
Expected Behavior
- ui-public build should be successful with appropriate bundles in dist/libs/ui-public folder
Steps to Reproduce
#<choose react as template and create 'sample' application>
#have couple of nested divs in the ui-public.tsx so the babel transform leverages jsxs variable to transform the TSX/JSX file. yarn
Failure Logs
Environment
Fix
this issue got fixed when I updated below code to include 'jsxs'. How do I override the rollupOptions within my project workspace ?
file: reactapp/node_modules/@nrwl/web/src/builders/package/package.impl.js function: createRollupOptions