Skip to content

Commit

Permalink
Remove next-routes (godaddy#240)
Browse files Browse the repository at this point in the history
* [minor] drop auto next-routes and old next build

* [doc] drop next-routes notes
  • Loading branch information
kinetifex authored Jan 5, 2021
1 parent 362fe88 commit 57a6d2b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 51 deletions.
1 change: 0 additions & 1 deletion packages/gasket-cli/docs/gotchas.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ CommonJS-style modules because they're imported directly by node:
* The Gasket config file (`gasket.config.js`)
* Your store creator (including files it imports, like reducers, action
constants, etc.) - typically `store.js`.
* Your routes creator (if using `next-routes`- typically `routes.js`).
* Lifecycle hooks (`/lifecycles/*.js`)
* Plugins (`/plugins/*.js`)

Expand Down
1 change: 0 additions & 1 deletion packages/gasket-plugin-nextjs/docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Ensure that the following files are included when you deploy your application:
- `package-lock.json` *Automatically generated file about the installed dependencies*
- `.babelrc` *Config file for babel*
- `gasket.config.js` *Config file for Gasket*
- `routes.js` *Routes for your application*
- `store.js` *Scripts for creating a redux store and/or attaching a reducer*

## Deployment checklist
Expand Down
1 change: 0 additions & 1 deletion packages/gasket-plugin-nextjs/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ your component with the [Next.js router HOC]: `withRouter`.
[Next.js documentation]:https://github.com/zeit/next.js
[Next.js routing]:https://github.com/zeit/next.js#routing
[Next.js router HOC]:https://github.com/zeit/next.js#using-a-higher-order-component
[next-routes]:https://github.com/fridays/next-routes
37 changes: 2 additions & 35 deletions packages/gasket-plugin-nextjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,34 +128,12 @@ module.exports = {
next();
});

// TODO: (@kinetifex) we no longer support next-routes - remove this
const { root, routes } = gasket.config || {};
const routesModulePath = path.join(root, routes || './routes');
let ssr;

try {
let router = require(routesModulePath);

// Handle ES6-style modules
if (router.default) {
router = router.default;
}

ssr = router.getRequestHandler(app);
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err;
}

ssr = app.getRequestHandler();
}

//
// Now that express has been setup, and users have been able to
// interact with the express router we want to add a last, catch all
// route that will activate the `next`.
//
expressApp.all('*', ssr);
expressApp.all('*', app.getRequestHandler());

return app;
},
Expand All @@ -164,18 +142,7 @@ module.exports = {
// Don't do a build, use dev server for local
if ((command.id || command) === 'local') return;

//
// Different versions of Nextjs, have different ways of exporting the builder.
// In order to support canary, and other versions of next we need to detect
// the different locations.
//
let builder;
try {
builder = require('next/dist/server/build').default;
} catch (e) {
builder = require('next/dist/build').default;
}

const builder = require('next/dist/build').default;
return await builder(path.resolve('.'), await createConfig(gasket, true));
},
/**
Expand Down
13 changes: 0 additions & 13 deletions packages/gasket-plugin-nextjs/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,6 @@ describe('build hook', () => {
await buildHook({ command: 'local' });
assume(builderStub).not.called();
});

it('supports older next build', async () => {
const oldBuilderStub = stub();
const buildHook = getMockedBuildHook({
'next/dist/server/build': {
default: oldBuilderStub
}
});
await buildHook({ command: { id: 'build' } });

assume(oldBuilderStub).called();
assume(builderStub).not.called();
});
});

describe('workbox hook', () => {
Expand Down

0 comments on commit 57a6d2b

Please sign in to comment.