diff --git a/packages/gasket-nextjs/CHANGELOG.md b/packages/gasket-nextjs/CHANGELOG.md index 80e597d8c..624b222a2 100644 --- a/packages/gasket-nextjs/CHANGELOG.md +++ b/packages/gasket-nextjs/CHANGELOG.md @@ -1,5 +1,9 @@ # `@gasket/nextjs` + + +- Add file extensions to imports, fix package exports conflict ([#778]) + ### 6.45.2 - Refactor tests to Jest, update test scripts, add `cross-env`, remove obsolete `devDeps` ([#670]) @@ -63,3 +67,4 @@ [#603]: https://github.com/godaddy/gasket/pull/603 [#614]: https://github.com/godaddy/gasket/pull/614 [#670]: https://github.com/godaddy/gasket/pull/670 +[#778]: https://github.com/godaddy/gasket/pull/778 diff --git a/packages/gasket-nextjs/lib/document/index.js b/packages/gasket-nextjs/lib/document/index.js index d565905af..52e8412f5 100644 --- a/packages/gasket-nextjs/lib/document/index.js +++ b/packages/gasket-nextjs/lib/document/index.js @@ -1,7 +1,7 @@ /// import { Children, cloneElement, createElement } from 'react'; -import { Main, NextScript } from 'next/document'; +import { Main, NextScript } from 'next/document.js'; // Conflicts with package.json exports - extensions required import { GasketDataScript } from '../gasket-data-script.js'; const reClass = /^class\s/; diff --git a/packages/gasket-nextjs/lib/index.js b/packages/gasket-nextjs/lib/index.js index bc55b335a..2b9b8271b 100644 --- a/packages/gasket-nextjs/lib/index.js +++ b/packages/gasket-nextjs/lib/index.js @@ -1,2 +1,2 @@ -export * from './use-gasket-data'; -export * from './with-gasket-data-provider'; +export * from './use-gasket-data.js'; +export * from './with-gasket-data-provider.js'; diff --git a/packages/gasket-nextjs/lib/server/index.js b/packages/gasket-nextjs/lib/server/index.js index 91d7de7d3..5cea854c8 100644 --- a/packages/gasket-nextjs/lib/server/index.js +++ b/packages/gasket-nextjs/lib/server/index.js @@ -1 +1 @@ -export { request } from './request'; +export { request } from './request.js'; diff --git a/packages/gasket-nextjs/lib/use-gasket-data.js b/packages/gasket-nextjs/lib/use-gasket-data.js index fcc417a38..3edef9259 100644 --- a/packages/gasket-nextjs/lib/use-gasket-data.js +++ b/packages/gasket-nextjs/lib/use-gasket-data.js @@ -1,5 +1,5 @@ import { useContext } from 'react'; -import { GasketDataContext } from './gasket-data-provider'; +import { GasketDataContext } from './gasket-data-provider.js'; /** * React that fetches GasketData in elements context and returns it diff --git a/packages/gasket-nextjs/lib/with-gasket-data-provider.js b/packages/gasket-nextjs/lib/with-gasket-data-provider.js index 538487dc3..7706dac77 100644 --- a/packages/gasket-nextjs/lib/with-gasket-data-provider.js +++ b/packages/gasket-nextjs/lib/with-gasket-data-provider.js @@ -1,5 +1,5 @@ import { createElement } from 'react'; -import { GasketDataProvider } from './gasket-data-provider'; +import { GasketDataProvider } from './gasket-data-provider.js'; import PropTypes from 'prop-types'; /** diff --git a/packages/gasket-plugin-nextjs/CHANGELOG.md b/packages/gasket-plugin-nextjs/CHANGELOG.md index 36d4cc1d1..534d342a2 100644 --- a/packages/gasket-plugin-nextjs/CHANGELOG.md +++ b/packages/gasket-plugin-nextjs/CHANGELOG.md @@ -1,5 +1,7 @@ # `@gasket/plugin-nextjs` +- Fix logic for `server.js` generation to include `customServer` ([#778]) +- Update generated `_document.js` ([#778]) - Added redux optional flag ([#762]) - Add plugin import to gasket file ([#736]) - Add itself to the app package file ([#736]) @@ -283,3 +285,4 @@ [#736]: https://github.com/godaddy/gasket/pull/736 [#750]: https://github.com/godaddy/gasket/pull/750 [#762]: https://github.com/godaddy/gasket/pull/762 +[#778]: https://github.com/godaddy/gasket/pull/778 diff --git a/packages/gasket-plugin-nextjs/generator/app/pages/_document.js b/packages/gasket-plugin-nextjs/generator/app/pages/_document.js index cc8d276a6..5099f7997 100644 --- a/packages/gasket-plugin-nextjs/generator/app/pages/_document.js +++ b/packages/gasket-plugin-nextjs/generator/app/pages/_document.js @@ -1,3 +1,4 @@ import Document from 'next/document'; -import { withGasketData } from '@gasket/nextjs'; -export default withGasketData()(Document); +import { withGasketData } from '@gasket/nextjs/document'; +import gasket from '../gasket.js'; +export default withGasketData(gasket)(Document.default || Document); diff --git a/packages/gasket-plugin-nextjs/lib/create.js b/packages/gasket-plugin-nextjs/lib/create.js index 53b539bb8..961a6e19f 100644 --- a/packages/gasket-plugin-nextjs/lib/create.js +++ b/packages/gasket-plugin-nextjs/lib/create.js @@ -41,9 +41,12 @@ function createTestFiles({ files, generatorDir, testPlugins }) { * @property {nextDevProxy} - Selected dev proxy from prompt * @property {typescript} - Selected typescript from prompt */ -function createNextFiles({ files, generatorDir, nextDevProxy, typescript }) { +function createNextFiles({ files, generatorDir, nextDevProxy, typescript, nextServerType }) { let glob; - if (typescript || !nextDevProxy) glob = `${generatorDir}/next/*[!server].js`; + if ( + typescript || + (!nextDevProxy && nextServerType === 'defaultServer') + ) glob = `${generatorDir}/next/*[!server].js`; else glob = `${generatorDir}/next/*`; files.add(glob); } @@ -70,7 +73,7 @@ function configureSitemap({ files, pkg, generatorDir }) { * addDependencies * @property {PackageJsonBuilder} pkg - The Gasket PackageJson API. */ -function addDependencies({ pkg, nextDevProxy }) { +function addDependencies({ pkg }) { pkg.add('dependencies', { '@gasket/assets': devDependencies['@gasket/assets'], '@gasket/nextjs': devDependencies['@gasket/nextjs'], @@ -81,11 +84,9 @@ function addDependencies({ pkg, nextDevProxy }) { 'react-dom': devDependencies['react-dom'] }); - if (nextDevProxy) { - pkg.add('devDependencies', { - nodemon: devDependencies.nodemon - }); - } + pkg.add('devDependencies', { + nodemon: devDependencies.nodemon + }); } /** @@ -174,8 +175,8 @@ module.exports = { createAppFiles({ files, generatorDir }); createTestFiles({ files, generatorDir, testPlugins }); - createNextFiles({ files, generatorDir, nextDevProxy, typescript }); - addDependencies({ pkg, nextDevProxy }); + createNextFiles({ files, generatorDir, nextDevProxy, typescript, nextServerType }); + addDependencies({ pkg }); addNpmScripts({ pkg, nextServerType, nextDevProxy, typescript }); addConfig(context); if (addSitemap) configureSitemap({ files, pkg, generatorDir });