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

feat!: remove magic exports support #6895

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/v2-remove-magic-exports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"remix": major
"@remix-run/cloudflare": major
"@remix-run/dev": major
"@remix-run/node": major
"@remix-run/react": major
"@remix-run/server-runtime": major
"@remix-run/testing": major
---

Removed support for "magic exports" from the `remix` package. This package can be removed from your `package.json` and you should update all imports to use the source `@remix-run/*` packages:

```diff
- import type { ActionArgs } from "remix";
- import { json, useLoaderData } from "remix";
+ import type { ActionArgs } from "@remix-run/node";
+ import { json } from "@remix-run/node";
+ import { useLoaderData } from "@remix-run/react";
```
53 changes: 0 additions & 53 deletions integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,59 +177,6 @@ test.describe("cloudflare compiler", () => {
);
});

// TODO: remove this when we get rid of that feature.
test("magic imports still works", async () => {
let magicExportsForNode = [
"createCookie",
"createCookieSessionStorage",
"createMemorySessionStorage",
"createSessionStorage",
"createSession",
"createWorkersKVSessionStorage",
"isCookie",
"isSession",
"json",
"redirect",
"Form",
"Link",
"Links",
"LiveReload",
"Meta",
"NavLink",
"Outlet",
"PrefetchPageLinks",
"RemixBrowser",
"RemixServer",
"Scripts",
"ScrollRestoration",
"useActionData",
"useBeforeUnload",
"useCatch",
"useFetcher",
"useFetchers",
"useFormAction",
"useHref",
"useLoaderData",
"useLocation",
"useMatches",
"useNavigate",
"useNavigationType",
"useOutlet",
"useOutletContext",
"useParams",
"useResolvedPath",
"useSearchParams",
"useSubmit",
];
let magicRemix = await fs.readFile(
path.resolve(projectDir, "node_modules/remix/dist/index.js"),
"utf8"
);
for (let name of magicExportsForNode) {
expect(magicRemix).toContain(name);
}
});

test("node externals are not bundled in the browser bundle", async () => {
let browserBundle = findBrowserBundle(projectDir);
let browserCodeFiles = await findCodeFiles(browserBundle);
Expand Down
56 changes: 0 additions & 56 deletions integration/compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,62 +311,6 @@ test.describe("compiler", () => {
expect(fontFile).toBeTruthy();
});

// TODO: remove this when we get rid of that feature.
test("magic imports still works", async () => {
let magicExportsForNode = [
"createCookie",
"createCookieSessionStorage",
"createFileSessionStorage",
"createMemorySessionStorage",
"createSessionStorage",
"unstable_createFileUploadHandler",
"unstable_createMemoryUploadHandler",
"unstable_parseMultipartFormData",
"createSession",
"isCookie",
"isSession",
"json",
"redirect",
"Form",
"Link",
"Links",
"LiveReload",
"Meta",
"NavLink",
"Outlet",
"PrefetchPageLinks",
"RemixBrowser",
"RemixServer",
"Scripts",
"ScrollRestoration",
"useActionData",
"useBeforeUnload",
"useCatch",
"useFetcher",
"useFetchers",
"useFormAction",
"useHref",
"useLoaderData",
"useLocation",
"useMatches",
"useNavigate",
"useNavigationType",
"useOutlet",
"useOutletContext",
"useParams",
"useResolvedPath",
"useSearchParams",
"useSubmit",
];
let magicRemix = await fse.readFile(
path.resolve(fixture.projectDir, "node_modules/remix/dist/index.js"),
"utf8"
);
for (let name of magicExportsForNode) {
expect(magicRemix).toContain(name);
}
});

test.describe("serverBareModulesPlugin", () => {
let ogConsole: typeof global.console;
test.beforeEach(() => {
Expand Down
2 changes: 0 additions & 2 deletions packages/remix-cloudflare/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const copy = require("rollup-plugin-copy");
const {
getOutputDir,
copyToPlaygrounds,
magicExportsPlugin,
isBareModuleId,
createBanner,
} = require("../../rollup.utils");
Expand Down Expand Up @@ -45,7 +44,6 @@ module.exports = function rollup() {
{ src: `${sourceDir}/README.md`, dest: outputDir },
],
}),
magicExportsPlugin({ packageName, version }),
copyToPlaygrounds(),
],
},
Expand Down
1 change: 0 additions & 1 deletion packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ describe("remix CLI", () => {
$ remix dev [projectDir]
$ remix routes [projectDir]
$ remix watch [projectDir]
$ remix setup [remixPlatform]

Options:
--help, -h Print this help message and exit
Expand Down
30 changes: 10 additions & 20 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { RemixConfig } from "../config";
import { readConfig } from "../config";
import { formatRoutes, RoutesFormat, isRoutesFormat } from "../config/format";
import { detectPackageManager } from "./detectPackageManager";
import { setupRemix, isSetupPlatform, SetupPlatform } from "./setup";
import { transpile as convertFileToJS } from "./useJavascript";
import type { Options } from "../compiler/options";
import { createFileWatchCache } from "../compiler/fileWatchCache";
Expand Down Expand Up @@ -68,25 +67,16 @@ export async function init(
}
}

export async function setup(platformArg?: string) {
let platform: SetupPlatform;
if (
platformArg === "cloudflare-workers" ||
platformArg === "cloudflare-pages"
) {
console.warn(
`Using '${platformArg}' as a platform value is deprecated. Use ` +
"'cloudflare' instead."
);
console.log("HINT: check the `postinstall` script in `package.json`");
platform = SetupPlatform.Cloudflare;
} else {
platform = isSetupPlatform(platformArg) ? platformArg : SetupPlatform.Node;
}

await setupRemix(platform);

console.log(`Successfully setup Remix for ${platform}.`);
/**
* Keep the function around in v2 so that users with `remix setup` in a script
* or postinstall hook can still run a build, but inform them that it's no
* longer necessary, and we can remove it in v3.
* @deprecated
*/
export function setup() {
console.warn(
"WARNING: The setup command is no longer necessary as of v2. This is a no-op. Please remove this from your dev and CI scripts, as it will be removed in v3."
);
}

export async function routes(
Expand Down
3 changes: 1 addition & 2 deletions packages/remix-dev/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ${colors.logoBlue("R")} ${colors.logoGreen("E")} ${colors.logoYellow(
$ remix dev [${colors.arg("projectDir")}]
$ remix routes [${colors.arg("projectDir")}]
$ remix watch [${colors.arg("projectDir")}]
$ remix setup [${colors.arg("remixPlatform")}]

${colors.heading("Options")}:
--help, -h Print this help message and exit
Expand Down Expand Up @@ -219,7 +218,7 @@ export async function run(argv: string[] = process.argv.slice(2)) {
await commands.watch(input[1], process.env.NODE_ENV);
break;
case "setup":
await commands.setup(input[1]);
commands.setup();
break;
case "reveal": {
// TODO: simplify getting started guide
Expand Down
121 changes: 0 additions & 121 deletions packages/remix-dev/cli/setup.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/remix-dev/compiler/js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { loaders } from "../utils/loaders";
import { browserRouteModulesPlugin } from "./plugins/routes";
import { cssFilePlugin } from "../plugins/cssImports";
import { absoluteCssUrlsPlugin } from "../plugins/absoluteCssUrlsPlugin";
import { deprecatedRemixPackagePlugin } from "../plugins/deprecatedRemixPackage";
import { emptyModulesPlugin } from "../plugins/emptyModules";
import { mdxPlugin } from "../plugins/mdx";
import { externalPlugin } from "../plugins/external";
Expand Down Expand Up @@ -88,7 +87,6 @@ const createEsbuildConfig = (

let plugins: esbuild.Plugin[] = [
browserRouteModulesPlugin(ctx, /\?browser$/),
deprecatedRemixPackagePlugin(ctx),
cssBundlePlugin(refs),
cssModulesPlugin(ctx, { outputCss: false }),
vanillaExtractPlugin(ctx, { outputCss: false }),
Expand Down
28 changes: 0 additions & 28 deletions packages/remix-dev/compiler/plugins/deprecatedRemixPackage.ts

This file was deleted.

Loading