Skip to content

Commit

Permalink
chore: move babel plugins from core package to internal (redwoodjs#3518)
Browse files Browse the repository at this point in the history
* Move babel plugins from core -> internal.

* Fix build.

* Fix lint.

* Fix babel-mock-cell-data plugin.

* Fix routes auto-loader tests.

* Fix core-js version detection.

* Whoops, these core-js settings are weird.

* TO DO: replace any type

* fix require paths to internal

* revert to pass tests

* revert plugin-rw-mock-cell-data and files

* fix TS errors

* update yarn.lock

* fix repgrap issue; update yarn.lock

* Update packages/core/README.md

* revert  API babel config removal

* fix ast types

* fix imports

Co-authored-by: Peter Pistorius <peter.pistorius@gmail.com>
  • Loading branch information
thedavidprice and peterp authored Oct 22, 2021
1 parent 1b21f68 commit 3b0e07c
Show file tree
Hide file tree
Showing 65 changed files with 130 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'dist',
'fixtures',
'packages/structure/**',
'packages/internal/src/build/babelPlugins/__tests__/__fixtures__/**/*',
'packages/core/**/__fixtures__/**/*',
'packages/codemods/**/__testfixtures__/**/*',
'packages/core/config/storybook/**/*',
Expand Down Expand Up @@ -108,7 +109,6 @@ module.exports = {
'packages/api/src/**',
'packages/api-server/src/**',
'packages/cli/src/**',
'packages/core/src/**',
'packages/core/config/**',
'packages/create-redwood-app/src/create-redwood-app.js',
'packages/internal/src/**',
Expand Down
2 changes: 2 additions & 0 deletions __fixtures__/example-todo-main/web/src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import { Private, Router, Route } from '@redwoodjs/router'
import SetLayout from 'src/layouts/SetLayout'

import FooPage from 'src/pages/FooPage'

const Routes = () => {
return (
<Router>
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"outDir": "dist",
},
"include": ["src", "ambient.d.ts"],
"references": [{ "path": "../internal" }, { "path": "../core" }]
"references": [{ "path": "../internal" }]
}
2 changes: 1 addition & 1 deletion packages/codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"node-fetch": "2.6.1",
"tasuku": "1.0.2",
"toml": "3.0.0",
"vscode-ripgrep": "1.0.0",
"vscode-ripgrep": "1.12.1",
"yargs": "16.2.0"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion packages/core/.babelrc.js

This file was deleted.

28 changes: 4 additions & 24 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
# Core

<!-- toc -->
- [Purpose and Vision](#Purpose-and-Vision)
- [Package Lead](#Package-Lead)
- [Roadmap](#Roadmap)
- [Contributing](#Contributing)
- [FAQ](#FAQ)
This package contains configuration and common dependencies required by a RedwoodJS project.

## Purpose and Vision
Provides the base level configuration and modules for Redwood.

## Package Lead

- @peterp

## Roadmap

- [ ] Introduce top-level exports for node and browser contexts, since right now we're fixing the concerns, and it might be clear what should work where.

## Contributing

TODO

## FAQ

TODO
## Package Leads
- @peterp
- @thedavidprice
33 changes: 25 additions & 8 deletions packages/core/config/babel-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ const CORE_JS_VERSION = packageJSON.dependencies['core-js']
.split('.')
.slice(0, 2)
.join('.') // Produces: 3.12, instead of 3.12.1
if (!CORE_JS_VERSION) {
throw new Error(
'RedwoodJS Project Babel: Could not determine core-js version.'
)
}

const RUNTIME_CORE_JS_VERSION =
packageJSON.dependencies['@babel/runtime-corejs3']
if (!RUNTIME_CORE_JS_VERSION) {
throw new Error(
'RedwoodJS Project Babel: Could not determine core-js runtime version'
)
}

/** @type {import('@babel/core').TransformOptions} */
module.exports = () => {
Expand All @@ -37,16 +50,16 @@ module.exports = () => {
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#version
// Transform-runtime assumes that @babel/runtime@7.0.0 is installed.
// Specifying the version can result in a smaller bundle size.
version: packageJSON.devDependencies['@babel/runtime-corejs3'],
version: RUNTIME_CORE_JS_VERSION,
},
],

[
require('../dist/babelPlugins/babel-plugin-redwood-directory-named-import'),
require('@redwoodjs/internal/dist/build/babelPlugins/babel-plugin-redwood-directory-named-import'),
],
],
overrides: [
// ** API **
// ** API (also applies to Jest API config) **
// ** SCRIPTS **
{
test: ['./api/', './scripts/'],
presets: [
Expand Down Expand Up @@ -100,7 +113,9 @@ module.exports = () => {
},
],
['babel-plugin-graphql-tag'],
[require('../dist/babelPlugins/babel-plugin-redwood-import-dir')],
[
require('@redwoodjs/internal/dist/build/babelPlugins/babel-plugin-redwood-import-dir'),
],
],
},
// ** WEB **
Expand Down Expand Up @@ -185,15 +200,17 @@ module.exports = () => {
// ** Files ending in `Cell.[js,ts]` **
{
test: /.+Cell.(js|tsx)$/,
plugins: [require('../dist/babelPlugins/babel-plugin-redwood-cell')],
plugins: [
require('@redwoodjs/internal/dist/build/babelPlugins/babel-plugin-redwood-cell'),
],
},
// Automatically import files in `./web/src/pages/*` in to
// the `./web/src/Routes.[ts|jsx]` file.
{
test: ['./web/src/Routes.js', './web/src/Routes.tsx'],
plugins: [
[
require('../dist/babelPlugins/babel-plugin-redwood-routes-auto-loader'),
require('@redwoodjs/internal/dist/build/babelPlugins/babel-plugin-redwood-routes-auto-loader'),
{
useStaticImports: process.env.__REDWOOD__PRERENDERING === '1',
},
Expand All @@ -205,7 +222,7 @@ module.exports = () => {
{
test: /.+Cell.mock.(js|ts)$/,
plugins: [
require('../dist/babelPlugins/babel-plugin-redwood-mock-cell-data'),
require('@redwoodjs/internal/dist/build/babelPlugins/babel-plugin-redwood-mock-cell-data'),
],
},
],
Expand Down
5 changes: 0 additions & 5 deletions packages/core/jest.config.js

This file was deleted.

22 changes: 2 additions & 20 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
"version": "0.37.5",
"license": "MIT",
"files": [
"config",
"dist"
"config"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@babel/cli": "7.15.4",
"@babel/core": "7.15.5",
Expand Down Expand Up @@ -63,20 +60,5 @@
"webpack-merge": "5.8.0",
"webpack-retry-chunk-load-plugin": "2.2.0"
},
"devDependencies": {
"@types/babel-core": "6.25.7",
"@types/babel-plugin-tester": "9.0.4",
"babel-plugin-tester": "10.1.0",
"jest": "27.2.0"
},
"gitHead": "8be6a35c2dfd5aaeb12d55be4f0c77eefceb7762",
"scripts": {
"build": "yarn build:js && yarn build:types",
"prepublishOnly": "yarn build",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"test": "jest src",
"test:watch": "yarn test --watch"
}
"gitHead": "8be6a35c2dfd5aaeb12d55be4f0c77eefceb7762"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions packages/core/src/getConfig.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/core/tsconfig.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@
},
"devDependencies": {
"@babel/cli": "7.15.4",
"@types/babel-plugin-tester": "9.0.4",
"@types/babel__core": "7.1.16",
"@types/findup-sync": "4.0.1",
"@types/fs-extra": "9.0.12",
"@types/rimraf": "3.0.2",
"babel-plugin-tester": "10.1.0",
"graphql-tag": "2.12.5",
"jest": "27.2.0",
"typescript": "4.4.3"
},
"jest": {
"testPathIgnorePatterns": [
"/fixtures/"
"/fixtures/",
"/__fixtures__/"
]
},
"scripts": {
Expand Down
Loading

0 comments on commit 3b0e07c

Please sign in to comment.