Skip to content

Commit

Permalink
More build stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Sep 8, 2020
1 parent b763e4d commit f4873e3
Show file tree
Hide file tree
Showing 15 changed files with 320 additions and 138 deletions.
21 changes: 0 additions & 21 deletions babel.config.cjs

This file was deleted.

14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current"
}
}
],
"@babel/preset-react",
"@babel/preset-typescript"
]
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
module.exports = {
projects: [
"<rootDir>/packages/core",
"<rootDir>/packages/express",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"private": true,
"name": "remix",
"type": "module",
"scripts": {
"clean": "git clean -fdX .",
"build": "node ./scripts/build.js",
"build": "rollup -c",
"publish": "node ./scripts/publish.js",
"test": "node ./scripts/test.js",
"test": "jest",
"version": "node ./scripts/version.js"
},
"workspaces": [
Expand All @@ -19,6 +18,7 @@
"@babel/preset-env": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@rollup/plugin-babel": "^5.2.0",
"@types/jest": "^25.2.3",
"@types/react": "^16.9.41",
"@types/react-test-renderer": "^16.9.2",
Expand All @@ -43,6 +43,7 @@
"react-router-dom": "0.0.0-experimental-ffd8c7d0",
"react-test-renderer": "0.0.0-experimental-33c3af284",
"rollup": "^2.21.0",
"rollup-plugin-copy": "^3.3.0",
"semver": "^7.3.2",
"typescript": "^3.9.6"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/readRemixConfig-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("readRemixConfig", () => {
let config = await readRemixConfig(root);
expect(config).toMatchInlineSnapshot(`
Object {
"appRoot": "/Users/ryan/Work/remix/fixtures/gists-app",
"appRoot": "/Users/michael/Projects/remix/fixtures/gists-app",
"devServer": Object {
"port": 8002,
},
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "@remix-run/core",
"version": "0.0.0",
"repository": "https://github.com/remix-run/packages",
"type": "commonjs",
"dependencies": {
"history": "^5.0.0",
"react": "0.0.0-experimental-33c3af284",
"react-dom": "0.0.0-experimental-33c3af284",
"react-router-dom": "0.0.0-experimental-ffd8c7d0"
}
},
"main": "index.cjs",
"module": "index.js"
}
1 change: 0 additions & 1 deletion packages/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@remix-run/express",
"version": "0.0.0",
"repository": "https://github.com/remix-run/packages",
"type": "commonjs",
"dependencies": {
"@remix-run/core": "0.0.0"
}
Expand Down
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@remix-run/react",
"version": "0.0.0",
"repository": "https://github.com/remix-run/packages",
"type": "commonjs",
"peerDependencies": {
"history": ">=5",
"react": "0.0.0-experimental-33c3af284",
Expand Down
98 changes: 98 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import path from "path";
import copy from "rollup-plugin-copy";
import babel from "@rollup/plugin-babel";

/** @type {import('rollup').RollupOptions} */
let core = {
input: path.resolve(__dirname, "packages/core/index.ts"),
output: {
file: "build/@remix-run/core/index.js",
format: "cjs"
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"]
}),
copy({
targets: [
{
src: path.resolve(__dirname, "packages/core/package.json"),
dest: "build/@remix-run/core"
}
]
})
]
};

/** @type {import('rollup').RollupOptions} */
let express = {
external: ["@remix-run/core"],
input: path.resolve(__dirname, "packages/express/index.ts"),
output: {
file: "build/@remix-run/express/index.js",
format: "cjs"
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"]
}),
copy({
targets: [
{
src: path.resolve(__dirname, "packages/express/package.json"),
dest: "build/@remix-run/express"
}
]
})
]
};

/** @type {import('rollup').RollupOptions[]} */
let react = [
{
external: ["react"],
input: path.resolve(__dirname, "packages/react/index.tsx"),
output: {
file: "build/@remix-run/react/index.js",
format: "esm"
},
plugins: [
// TODO: Don't rely on main babel.config.js which targets node: current.
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"]
}),
copy({
targets: [
{
src: path.resolve(__dirname, "packages/react/package.json"),
dest: "build/@remix-run/react"
}
]
})
]
},
// Also provide CommonJS build for webpack.
{
external: ["react"],
input: path.resolve(__dirname, "packages/react/index.tsx"),
output: {
file: "build/@remix-run/react/index.cjs",
format: "cjs"
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"]
})
]
}
];

export default [core, express, ...react];
33 changes: 0 additions & 33 deletions scripts/build.js

This file was deleted.

14 changes: 6 additions & 8 deletions scripts/publish.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import path from "path";
import { promises as fsp } from "fs";
import { exec, spawn } from "child_process";
import { promisify } from "util";
import { fileURLToPath } from "url";
const path = require("path");
const fsp = require("fs").promises;
const { exec, spawn } = require("child_process");
const { promisify } = require("util");

const dirname = path.dirname(fileURLToPath(import.meta.url));
const buildDir = path.resolve(dirname, "../build/@remix-run");
const buildDir = path.resolve(__dirname, "../build/@remix-run");

const x = promisify(exec);

Expand Down Expand Up @@ -36,7 +34,7 @@ async function run() {

// 1. Publish all packages, starting with core
let buildNames = await fsp.readdir(buildDir);
buildNames.sort((a, b) => (a === "core" ? -1 : 0));
buildNames.sort(a => (a === "core" ? -1 : 0));

for (let name of buildNames) {
await npm(["publish", path.join(buildDir, name)], {
Expand Down
48 changes: 0 additions & 48 deletions scripts/test.js

This file was deleted.

16 changes: 7 additions & 9 deletions scripts/version.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import path from "path";
import { fileURLToPath } from "url";
import { execSync } from "child_process";
const path = require("path");
const { execSync } = require("child_process");

import chalk from "chalk";
import Confirm from "prompt-confirm";
import jsonfile from "jsonfile";
import semver from "semver";
const chalk = require("chalk");
const Confirm = require("prompt-confirm");
const jsonfile = require("jsonfile");
const semver = require("semver");

const dirname = path.dirname(fileURLToPath(import.meta.url));
const packagesDir = path.resolve(dirname, "../packages");
const packagesDir = path.resolve(__dirname, "../packages");

function invariant(cond, message) {
if (!cond) throw new Error(message);
Expand Down
10 changes: 3 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"compilerOptions": {
"noEmit": true,

"lib": ["esnext", "dom", "dom.iterable"],
"moduleResolution": "node",
"esModuleInterop": true,
Expand All @@ -8,13 +10,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,

"target": "es2018",
"module": "commonjs",
"outDir": "build/@remix-run",
"declaration": true,
"sourceMap": true
"noImplicitReturns": true
},
"include": ["types/**/*", "packages/**/*"],
"exclude": [
Expand Down
Loading

0 comments on commit f4873e3

Please sign in to comment.