Skip to content

Commit

Permalink
latest exploration - still failing
Browse files Browse the repository at this point in the history
  • Loading branch information
flybayer committed Apr 18, 2020
1 parent 4e74220 commit 7baa6a9
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
4 changes: 2 additions & 2 deletions examples/store/db/index.ts
@@ -1,5 +1,5 @@
import {PrismaClient} from '.generated-prisma-client'
export * from '.generated-prisma-client'
import {PrismaClient} from './.generated-prisma-client'
export * from './.generated-prisma-client'

const prisma = new PrismaClient()

Expand Down
2 changes: 1 addition & 1 deletion examples/store/db/schema.prisma
Expand Up @@ -8,7 +8,7 @@ datasource postgresql {

generator client {
provider = "prisma-client-js"
output = "../.generated-prisma-client"
output = ".generated-prisma-client"
}


Expand Down
7 changes: 4 additions & 3 deletions examples/store/package.json
Expand Up @@ -8,8 +8,9 @@
"dependencies": {
"@blitzjs/cli": "0.0.2-canary.1.2",
"@blitzjs/core": "0.0.2-canary.1",
"@blitzjs/server": "0.0.2-canary.1.4",
"@prisma/client": "2.0.0-beta.2",
"@blitzjs/server": "0.0.2-canary.1.5",
"@prisma/cli": "2.0.0-alpha.1107",
"@prisma/client": "2.0.0-alpha.1107",
"final-form": "4.19.1",
"react": "0.0.0-experimental-e5d06e34b",
"react-dom": "0.0.0-experimental-e5d06e34b",
Expand All @@ -18,8 +19,8 @@
},
"NOTE": "Next.js dependency is only required for deploying to zeit, for now",
"devDependencies": {
"@types/react": "16.9.34",
"@prisma/cli": "2.0.0-beta.2",
"@types/react": "16.9.34",
"next": "9.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/cli/package.json
Expand Up @@ -43,7 +43,7 @@
"vinyl": "^2.2.0"
},
"devDependencies": {
"@blitzjs/server": "0.0.2-canary.1.4",
"@blitzjs/server": "0.0.2-canary.1.5",
"@oclif/dev-cli": "^1.22.2",
"@oclif/test": "^1.2.5",
"@types/cross-spawn": "^6.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
@@ -1,5 +1,5 @@
{
"version": "0.0.2-canary.1.4",
"version": "0.0.2-canary.1.5",
"license": "MIT",
"main": "dist/index.js",
"bin": {
Expand Down
37 changes: 30 additions & 7 deletions packages/server/src/withBlitz.ts
@@ -1,6 +1,27 @@
const withPlugins = require('next-compose-plugins')
const withTM = require('next-transpile-modules')(['@blitzjs/core'])
const resolveCwd = require('resolve-cwd')
// const resolveCwd = require('resolve-cwd')

class WebpackFileDirnamePlugin {
apply(compiler: any) {
compiler.hooks.compilation.tap('WebpackFileDirnamePlugin', (_: any, {normalModuleFactory}: any) => {
const handler = (parser: any) => {
const setModuleConstant = (expressionName: any, fn: Function) => {
parser.hooks.expression.for(expressionName).tap('WebpackFileDirnamePlugin', () => {
parser.state.current.addVariable(expressionName, JSON.stringify(fn(parser.state.module)))
return true
})
}

setModuleConstant('__filename', (module: any) => module.resource)
setModuleConstant('__dirname', (module: any) => module.context)
}

normalModuleFactory.hooks.parser.for('javascript/auto').tap('WebpackFileDirnamePlugin', handler)
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap('WebpackFileDirnamePlugin', handler)
})
}
}

export function withBlitz(nextConfig: Record<any, any> = {}) {
const plugins = []
Expand All @@ -23,12 +44,14 @@ export function withBlitz(nextConfig: Record<any, any> = {}) {
config.module.rules.push({test: /_rpc/, loader: require.resolve('null-loader')})
}

if (options.isServer) {
config.externals = config.externals || []
config.externals.push({
'.generated-prisma-client': resolveCwd('./.generated-prisma-client'),
})
}
config.plugins.push(new WebpackFileDirnamePlugin())

// if (process.env.NODE_ENV === 'development' && options.isServer) {
// config.externals = config.externals || []
// config.externals.push({
// './.generated-prisma-client': resolveCwd('./db/.generated-prisma-client'),
// })
// }

if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Expand Up @@ -2338,10 +2338,15 @@
dependencies:
"@types/node" ">= 8"

"@prisma/cli@2.0.0-beta.2":
version "2.0.0-beta.2"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-2.0.0-beta.2.tgz#5252cbe458fd7de479a6697ab5cffd1659a5762c"
integrity sha512-lD0cv/YC4g4SKByxH3hvzX1oS9cjRdCDU1Sh2inATaKcTHWPlxxgXQW4yYU2FF/HSWR9KK6YMAdO3ShkOl1PEQ==
"@prisma/cli@2.0.0-alpha.1107":
version "2.0.0-alpha.1107"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-2.0.0-alpha.1107.tgz#d0d4142875e47fe7d9bebb90bacad5b23315fa52"
integrity sha512-mdDe2PG/z8iGSLYfOJ4y8TmKAXgso4tPpDeYAlNd9k0rXQc9B/mIlgcr8w3UlF1+7jQ0Me1W33jgvihjVmEW5w==

"@prisma/client@2.0.0-alpha.1107":
version "2.0.0-alpha.1107"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-2.0.0-alpha.1107.tgz#d3093a26019e61b9a337154c352041337633a088"
integrity sha512-wH2QenXdnolZz0+0cgO4LalMc2dnE/pR/EO7juWk/oQONDjczxyrE+sblZv6XljTHxx7r7APGwTnTBA1tIfqvQ==

"@prisma/client@2.0.0-beta.2":
version "2.0.0-beta.2"
Expand Down

0 comments on commit 7baa6a9

Please sign in to comment.