Skip to content

Commit

Permalink
Merge branch 'feat/rsc-build' of github.com:dac09/redwood into feat/r…
Browse files Browse the repository at this point in the history
…sc-build

* 'feat/rsc-build' of github.com:dac09/redwood: (32 commits)
  RSC: ensureProcessDirWeb() (redwoodjs#10108)
  Comment on ensureProcessDirWeb()
  Remove redundant cwd check
  RSC: Extract webpack shims into their own file (redwoodjs#10107)
  RSC: Remove completed TODO comment
  RSC: Babel react plugin not needed for analyze phase (redwoodjs#10106)
  Remove handled TODO
  RSC: runFeServer: wrap RSC code with `if (rscEnabled)` (redwoodjs#10105)
  Only comment about swc in one place
  Remove duplicated comment (exists further down)
  RSC: Update comments, naming etc based on Danny's input (redwoodjs#10104)
  RSC: Rename to buildRscClientAndServer (redwoodjs#10103)
  RSC: Rename to rscBuildForServer, and tweak some comments (redwoodjs#10102)
  SSR: Extract buildForStreamingServer function (redwoodjs#10099)
  chore(unit-tests): Silence middleware error logging (redwoodjs#10097)
  Iterate on `.env` files: make the behavior override (redwoodjs#10094)
  RSC: smoke-tests: Compare text, not html (redwoodjs#10098)
  paths.ts: Move helper to esm section
  More comment formatting
  getMergedConfig comment format
  ...
  • Loading branch information
dac09 committed Mar 4, 2024
2 parents 69abdd8 + ba48fc3 commit 5ac8c2b
Show file tree
Hide file tree
Showing 75 changed files with 613 additions and 6,825 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ jobs:
working-directory: ./tasks/e2e
spec: |
cypress/e2e/01-tutorial/*.cy.js
cypress/e2e/04-logger/*.cy.js
- uses: actions/upload-artifact@v4
if: always()
Expand Down
36 changes: 21 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

- fix(deps): update prisma monorepo to v5.10.2 (#10088)

This release updates Prisma to v5.10.2. Here are quick links to all the release notes since the last version (v5.9.1):

- https://github.com/prisma/prisma/releases/tag/5.10.0
- https://github.com/prisma/prisma/releases/tag/5.10.1
- https://github.com/prisma/prisma/releases/tag/5.10.2

- fix(deps): update opentelemetry-js monorepo (#10065)

Updates our opentelemetry packages. This is a breaking change for users of
Expand Down Expand Up @@ -29,28 +37,26 @@
DataDog/import-in-the-middle#57
* This version does not support Node.js 18.19 or later

- Add support for additional env var files (#9961)
- Add support for loading more env var files (#9961, #10093, and #10094)

Fixes #9877. This PR adds a new middleware step to the CLI that looks for an `--include-env-files` flag and includes `.env.[file]` to the list of dotfiles to load. This PR also introduces functionality so that `.env.[file]` files are loaded based on `NODE_ENV`.
Fixes #9877. This PR adds CLI functionality to load more `.env` files via `NODE_ENV` and an `--add-env-files` flag.
Env vars loaded via either of these methods override the values in `.env`:

Using the `--include-env-files` flag:

```bash
yarn rw exec myScript --include-env-files prod stripe-prod
# Alternatively you can specify the flag twice:
yarn rw exec myScript --include-env-files prod --include-env-files stripe-prod
```

Using `NODE_ENV`:

```
# loads .env.production
# Loads '.env.production', which overrides values in '.env'
NODE_ENV=production yarn rw exec myScript
# Load '.env.stripe' and '.env.nakama', which overrides values
yarn rw exec myScript --add-env-files stripe --add-env-files nakama
# Or you can specify the flag once:
yarn rw exec myScript --add-env-files stripe nakama
```

These files are loaded in addition to `.env` and `.env.defaults` and more generally are additive. Subsequent dotfiles won't overwrite environment variables defined previous ones. As such, files loaded via NODE_ENV have lower priority than those loaded specifically via `--include-env-files`.
Note that this feature is mainly for local scripting. Most deploy providers don't let you upload `.env` files (unless you're using baremetal) and usually have their own way of determining environments.

## v7.0.6

Note that this feature is mainly for local scripting. Most deploy providers don't let you upload dotfiles and usually have their own way of determining environments.
- See https://github.com/redwoodjs/redwood/releases/tag/v7.0.6

## v7.0.5

Expand Down
35 changes: 1 addition & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,37 +343,4 @@ yarn rw upgrade --tag rc

## Publishing New Versions: `@latest`

> **New `yarn release` Publishing Command**
>
> As of February 2022, there's a new command `yarn release` that covers all the necessary steps:
>
> 1. starting with creating a release branch
> 2. to creating a milestone and assigning it to PRs
> 3. to preparing and publishing packages
> 4. to creating release notes
>
> 🚀
To publish a new version of Redwood to NPM, run the following commands:

> NOTE: `<version>` should be formatted like `v0.24.0` (for example)
```bash
git clean -dfx
yarn install
./tasks/update-package-versions <version>
git commit -am "<version>"
git tag -am <version> "<version>"
git push && git push --tags
yarn build
yarn lerna publish from-package
```

This...

1) changes the version of **all the packages** (even those that haven't changed),
2) changes the version of the packages within the CRWA Template
3) commits, tags, and pushes to GitHub
4) and finally publishes all packages to NPM.

If something went wrong you can use `yarn lerna publish from-package` to publish the packages that aren't already in the registry.
See https://github.com/redwoodjs/release-tooling.
2 changes: 1 addition & 1 deletion __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@redwoodjs/vite": "7.0.0",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.17",
"autoprefixer": "^10.4.18",
"postcss": "^8.4.35",
"postcss-loader": "^8.1.1",
"prettier-plugin-tailwindcss": "0.4.1",
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"project:tarsync": "node ./tasks/framework-tools/tarsync.mjs",
"rebuild-test-project-fixture": "tsx ./tasks/test-project/rebuild-test-project-fixture.ts",
"rebuild-fragments-test-project-fixture": "tsx ./tasks/test-project/rebuild-fragments-test-project-fixture.ts",
"release": "node ./tasks/release/release.mjs",
"release:compare": "node ./tasks/release/compare/compare.mjs",
"release:notes": "node ./tasks/release/generateReleaseNotes.mjs",
"release:triage": "node ./tasks/release/triage/triage.mjs",
"smoke-tests": "node ./tasks/smoke-tests/smoke-tests.mjs",
"test": "nx run-many -t test -- --minWorkers=1 --maxWorkers=4",
"test-ci": "nx run-many -t test",
Expand Down

This file was deleted.

49 changes: 22 additions & 27 deletions packages/api-server/src/plugins/lambdaLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,32 @@ export const setLambdaFunctions = async (foundFunctions: string[]) => {
const tsImport = Date.now()
console.log(chalk.dim.italic('Importing Server Functions... '))

const imports = foundFunctions.map((fnPath) => {
return new Promise((resolve) => {
const ts = Date.now()
const routeName = path.basename(fnPath).replace('.js', '')

const { handler } = require(fnPath)
LAMBDA_FUNCTIONS[routeName] = handler
if (!handler) {
console.warn(
routeName,
'at',
fnPath,
'does not have a function called handler defined.'
)
}
// TODO: Use terminal link.
console.log(
chalk.magenta('/' + routeName),
chalk.dim.italic(Date.now() - ts + ' ms')
const imports = foundFunctions.map(async (fnPath) => {
const ts = Date.now()
const routeName = path.basename(fnPath).replace('.js', '')

const { handler } = await import(`file://${fnPath}`)
LAMBDA_FUNCTIONS[routeName] = handler
if (!handler) {
console.warn(
routeName,
'at',
fnPath,
'does not have a function called handler defined.'
)
return resolve(true)
})
})

Promise.all(imports).then((_results) => {
}
// TODO: Use terminal link.
console.log(
chalk.dim.italic(
'...Done importing in ' + (Date.now() - tsImport) + ' ms'
)
chalk.magenta('/' + routeName),
chalk.dim.italic(Date.now() - ts + ' ms')
)
})

await Promise.all(imports)

console.log(
chalk.dim.italic('...Done importing in ' + (Date.now() - tsImport) + ' ms')
)
}

type LoadFunctionsFromDistOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.23.9",
"@prisma/client": "5.9.1",
"@prisma/client": "5.10.2",
"@whatwg-node/fetch": "0.9.16",
"core-js": "3.35.1",
"humanize-string": "2.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
38 changes: 24 additions & 14 deletions packages/babel-config/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path'
import type { PluginOptions, PluginTarget, TransformOptions } from '@babel/core'
import { transformAsync } from '@babel/core'

import { getPaths } from '@redwoodjs/project-config'
import { getPaths, projectSideIsEsm } from '@redwoodjs/project-config'

import type { RegisterHookOptions } from './common'
import {
Expand Down Expand Up @@ -74,11 +74,10 @@ type PluginShape =
| [PluginTarget, PluginOptions, undefined | string]
| [PluginTarget, PluginOptions]

export const getApiSideBabelPlugins = (
{ openTelemetry } = {
openTelemetry: false,
}
) => {
export const getApiSideBabelPlugins = ({
openTelemetry = false,
projectIsEsm = false,
} = {}) => {
const tsConfig = parseTypeScriptConfigFiles()

const plugins: Array<PluginShape | boolean> = [
Expand Down Expand Up @@ -128,7 +127,9 @@ export const getApiSideBabelPlugins = (
['babel-plugin-graphql-tag', undefined, 'rwjs-babel-graphql-tag'],
[
require('./plugins/babel-plugin-redwood-import-dir').default,
undefined,
{
projectIsEsm,
},
'rwjs-babel-glob-import-dir',
],
openTelemetry && [
Expand All @@ -150,7 +151,7 @@ export const getApiSideBabelConfigPath = () => {
}
}

export const getApiSideBabelOverrides = () => {
export const getApiSideBabelOverrides = ({ projectIsEsm = false } = {}) => {
const overrides = [
// Extract graphql options from the graphql function
// NOTE: this must come before the context wrapping
Expand All @@ -167,18 +168,23 @@ export const getApiSideBabelOverrides = () => {
// match */api/src/functions/*.js|ts
test: /.+api(?:[\\|/])src(?:[\\|/])functions(?:[\\|/]).+.(?:js|ts)$/,
plugins: [
require('./plugins/babel-plugin-redwood-context-wrapping').default,
[
require('./plugins/babel-plugin-redwood-context-wrapping').default,
{
projectIsEsm,
},
],
],
},
].filter(Boolean)
return overrides as TransformOptions[]
}

export const getApiSideDefaultBabelConfig = () => {
export const getApiSideDefaultBabelConfig = ({ projectIsEsm = false } = {}) => {
return {
presets: getApiSideBabelPresets(),
plugins: getApiSideBabelPlugins(),
overrides: getApiSideBabelOverrides(),
plugins: getApiSideBabelPlugins({ projectIsEsm }),
overrides: getApiSideBabelOverrides({ projectIsEsm }),
extends: getApiSideBabelConfigPath(),
babelrc: false,
ignore: ['node_modules'],
Expand All @@ -190,7 +196,9 @@ export const registerApiSideBabelHook = ({
plugins = [],
...rest
}: RegisterHookOptions = {}) => {
const defaultOptions = getApiSideDefaultBabelConfig()
const defaultOptions = getApiSideDefaultBabelConfig({
projectIsEsm: projectSideIsEsm('api'),
})

registerBabel({
...defaultOptions,
Expand All @@ -209,7 +217,9 @@ export const transformWithBabel = async (
plugins: TransformOptions['plugins']
) => {
const code = await fs.readFile(srcPath, 'utf-8')
const defaultOptions = getApiSideDefaultBabelConfig()
const defaultOptions = getApiSideDefaultBabelConfig({
projectIsEsm: projectSideIsEsm('api'),
})

const result = transformAsync(code, {
...defaultOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ function generateWrappedHandler(t: typeof types, isAsync: boolean) {
)
}

export default function ({ types: t }: { types: typeof types }): PluginObj {
export default function (
{ types: t }: { types: typeof types },
{ projectIsEsm = false }: { projectIsEsm?: boolean } = {}
): PluginObj {
return {
name: 'babel-plugin-redwood-context-wrapping',
visitor: {
Expand Down Expand Up @@ -97,7 +100,11 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
t.identifier('getAsyncStoreInstance')
),
],
t.stringLiteral('@redwoodjs/context/dist/store')
t.stringLiteral(
projectIsEsm
? '@redwoodjs/context/dist/store.js'
: '@redwoodjs/context/dist/store'
)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import { importStatementPath } from '@redwoodjs/project-config'
* // services.nested_c = require('src/services/nested/c.js')
* ```
*/
export default function ({ types: t }: { types: typeof types }): PluginObj {
export default function (
{ types: t }: { types: typeof types },
{ projectIsEsm = false }: { projectIsEsm?: boolean } = {}
): PluginObj {
return {
name: 'babel-plugin-redwood-import-dir',
visitor: {
Expand Down Expand Up @@ -74,7 +77,11 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
t.identifier(importName + '_' + fpVarName)
),
],
t.stringLiteral(filePathWithoutExtension)
t.stringLiteral(
projectIsEsm
? `${filePathWithoutExtension}.js`
: filePathWithoutExtension
)
)
)

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-packages/dataMigrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"yargs": "17.7.2"
},
"devDependencies": {
"@prisma/client": "5.9.1",
"@prisma/client": "5.10.2",
"@redwoodjs/framework-tools": "7.0.0",
"@types/fs-extra": "11.0.4",
"@types/yargs": "17.0.32",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ describe('upHandler', () => {
{
'redwood.toml': '',
api: {
'package.json': '{}',
dist: {
lib: {
'db.js': '',
Expand Down
Loading

0 comments on commit 5ac8c2b

Please sign in to comment.