我正在使用 纱线工作区,其中根目录具有包含所有我的存储库的包目录.每个repo都有自己的node_modules目录,其中包含其依赖项.根node_modules目录包含整个项目的所有dev依赖项以及所有其他dev相关的东西,例如webpack.config文件.Webpack使用热模块重新加载Express服务器包.
我遇到的问题是,如何配置webpack外部以通过整个项目排除所有node_modules目录,而不仅仅是在根目录中?
在这种情况下,webpack-node-externals似乎不起作用.
错误信息:
WARNING in ./packages/servers/express/node_modules/colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression
WARNING in ./packages/servers/express/node_modules/express/lib/view.js
79:29-41 Critical dependency: the request of a dependency is an expression
Run Code Online (Sandbox Code Playgroud)
Webpack配置:
const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const StartServerPlugin = require('start-server-webpack-plugin');
module.exports = {
entry: [
'babel-polyfill',
'webpack/hot/poll?1000',
path.join(__dirname, '../packages/servers/express/server/index.js')
],
watch: true,
target: 'node',
externals: [
nodeExternals({
whitelist: ['webpack/hot/poll?1000']
})
],
resolve: {
alias: {
handlebars: 'handlebars/dist/handlebars.js' …Run Code Online (Sandbox Code Playgroud) 如何使用现代接力中的新项目更新ui?
我有所有其他CRUD工作,但无法弄清楚新项目的提交突变的更新程序.当我刷新页面时.所有示例都使用查看器对象,我的架构中没有查看器对象.
schema.graphql
type Note {
id: String
avatar: String
message: String
date: String
}
Run Code Online (Sandbox Code Playgroud)
create_mutation.js
export function createMutation({ mutation, variables, environment, create }) {
const fragment = mutation().fragment;
const operation = fragment.selections[0].name;
const mutationName = fragment.name;
const type = fragment.selections[0].concreteType;
const id = 'client:${operation}:${cuid()}';
const config = {
mutation,
variables,
optimisticUpdater: proxyStore => {
// 1. Create mock record that to be added to the store
const record = proxyStore.create(id, type);
Object.keys({ ...variables, id }).forEach(key =>
record.setValue(key, `${key}`)
); …Run Code Online (Sandbox Code Playgroud)