Skip to content
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

Fix dataMigrate command import error via babel register #1845

Merged
merged 6 commits into from
Feb 24, 2021

Conversation

dac09
Copy link
Contributor

@dac09 dac09 commented Feb 24, 2021

Will fill in details tomorrow. Putting here for DP to get early access :)

dp edit below

The dataMigrate commands were throwing a strange import error regarding db.js and Prisma Client. This PR resolves the import error.

Screen Shot 2021-02-22 at 11 58 33 PM

@github-actions
Copy link

github-actions bot commented Feb 24, 2021

📦 PR Packages

Click to Show Package Download Links

https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/create-redwood-app-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-api-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-api-server-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-auth-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-cli-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-core-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-dev-server-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-eslint-config-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-eslint-plugin-redwood-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-forms-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-internal-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-prerender-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-router-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-structure-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-testing-0.25.1-e001326.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1845/redwoodjs-web-0.25.1-e001326.tgz

Install this PR by running yarn rw upgrade --pr 1845:0.25.1-e001326

import Listr from 'listr'
import VerboseRenderer from 'listr-verbose-renderer'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'

require('@babel/register')
babelRequireHook({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing this only increases my dislike for babel

@thedavidprice thedavidprice changed the title Fix how babel gets registered in dm install Fix dataMigrate command import error via babel register Feb 24, 2021
@thedavidprice
Copy link
Contributor

Progress. Getting an error but it's a new one:

$ yarn rw dm install                      
yarn run v1.22.10
$ /Users/price/Repos/xx-delete/node_modules/.bin/redwood dm install
/Users/price/Repos/xx-delete/node_modules/@redwoodjs/cli/node_modules/yargs/build/index.cjs:2772
                throw err;
                ^

Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
    at new PrismaClient (/Users/price/Repos/xx-delete/node_modules/.prisma/client/index.js:3:11)
    at Object.<anonymous> (/Users/price/Repos/xx-delete/api/src/lib/db.js:6:19)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._compile (/Users/price/Repos/xx-delete/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.newLoader [as .js] (/Users/price/Repos/xx-delete/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@dac09 dac09 marked this pull request as ready for review February 24, 2021 10:37
@dac09
Copy link
Contributor Author

dac09 commented Feb 24, 2021

Progress. Getting an error but it's a new one

I think this is possibly as expected. We could get datamigrate to build the prisma client before, but then it would slow down the whole command.

Off the top of my head I think the prisma client is built after rw upgrades and before building api automatically. Should we also have it here?

@thedavidprice
Copy link
Contributor

@dac09 The new rw prisma migrate dev command does generate the Prisma Client. So that's why this error is suspicious to me:

Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.

I did try running rw prisma generate before I ran rw dataMigrate install and it still gave the same error. So I don't think it's actually the problem here.

… fix/dm-babel-register

* 'fix/dm-babel-register' of github.com:dac09/redwood:
  Remove bundlesize dependency (redwoodjs#1844)
  upgrade execa; fix test.js cwd (redwoodjs#1846)
  Make ESLint configuration aware of "env." (redwoodjs#1827)
  Use createMany in Seed database example (redwoodjs#1776)
  Docs: Update contributor workflow to yarn rwt link (redwoodjs#1803)
  fix(page-loader): Adds types for pageLoadingContext | Fix for pageLoader during prerender (redwoodjs#1832)
  Minify CSS in production builds (redwoodjs#1697)
  New contributor workflow (redwoodjs#1792)
  Improve/template and auth setup tests (redwoodjs#1834)
@thedavidprice thedavidprice merged commit 8b48df3 into redwoodjs:main Feb 24, 2021
@thedavidprice thedavidprice added this to the next release milestone Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants