diff --git a/.changeset/install-globals.md b/.changeset/install-globals.md new file mode 100644 index 00000000000..7741b31d2ba --- /dev/null +++ b/.changeset/install-globals.md @@ -0,0 +1,6 @@ +--- +"@remix-run/node": patch +"@remix-run/serve": patch +--- + +add `@remix-run/node/install` side-effect to allow `node --require @remix-run/node/install` diff --git a/packages/remix-node/install.d.ts b/packages/remix-node/install.d.ts new file mode 100644 index 00000000000..cb0ff5c3b54 --- /dev/null +++ b/packages/remix-node/install.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/remix-node/install.js b/packages/remix-node/install.js new file mode 100644 index 00000000000..101e98eb263 --- /dev/null +++ b/packages/remix-node/install.js @@ -0,0 +1,8 @@ +/* eslint-disable */ +'use strict'; + +var globals = require('./dist/globals.js'); + +Object.defineProperty(exports, '__esModule', { value: true }); + +globals.installGlobals(); diff --git a/packages/remix-node/package.json b/packages/remix-node/package.json index 27d0ac211c2..7537f94ebaa 100644 --- a/packages/remix-node/package.json +++ b/packages/remix-node/package.json @@ -13,7 +13,7 @@ "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", - "sideEffects": false, + "sideEffects": ["./install.js"], "dependencies": { "@remix-run/server-runtime": "1.15.0", "@remix-run/web-fetch": "^4.3.2", diff --git a/packages/remix-node/rollup.config.js b/packages/remix-node/rollup.config.js index bc2cef39ebb..a9ca3dd4645 100644 --- a/packages/remix-node/rollup.config.js +++ b/packages/remix-node/rollup.config.js @@ -43,6 +43,11 @@ module.exports = function rollup() { { src: "LICENSE.md", dest: [outputDir, sourceDir] }, { src: `${sourceDir}/package.json`, dest: outputDir }, { src: `${sourceDir}/README.md`, dest: outputDir }, + // This needs to end up in the root of the pkg but also needs to + // reference other compiled files. Just copying these are easier + // than dealing with output configuration for sharing chunks x-builds. + { src: `${sourceDir}/install.js`, dest: outputDir }, + { src: `${sourceDir}/install.d.ts`, dest: outputDir }, ], }), magicExportsPlugin({ packageName, version }), diff --git a/packages/remix-serve/env.ts b/packages/remix-serve/env.ts index a212b1fa83e..5c1c352db25 100644 --- a/packages/remix-serve/env.ts +++ b/packages/remix-serve/env.ts @@ -1 +1,3 @@ +import "@remix-run/node/install"; + process.env.NODE_ENV = process.env.NODE_ENV || "production"; diff --git a/packages/remix-serve/package.json b/packages/remix-serve/package.json index 2b116261d58..2a9bbd9479b 100644 --- a/packages/remix-serve/package.json +++ b/packages/remix-serve/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "@remix-run/express": "1.15.0", + "@remix-run/node": "1.15.0", "compression": "^1.7.4", "express": "^4.17.1", "morgan": "^1.10.0"