diff --git a/packages/gasket-plugin-nextjs/lib/webpack-config.js b/packages/gasket-plugin-nextjs/lib/webpack-config.js index af56fa7a1..13d9f859c 100644 --- a/packages/gasket-plugin-nextjs/lib/webpack-config.js +++ b/packages/gasket-plugin-nextjs/lib/webpack-config.js @@ -53,6 +53,8 @@ function webpackConfigHook(gasket, webpackConfig, { webpack, isServer }) { if (!isServer) { exclude('./gasket.js'); exclude('./src/gasket.js'); + exclude('./gasket.mjs'); + exclude('./src/gasket.mjs'); exclude('./gasket.ts'); exclude('./src/gasket.ts'); exclude('./dist/gasket.js'); diff --git a/packages/gasket-plugin-nextjs/test/webpack-config.test.js b/packages/gasket-plugin-nextjs/test/webpack-config.test.js index 4aa3f350a..1ab3e59ba 100644 --- a/packages/gasket-plugin-nextjs/test/webpack-config.test.js +++ b/packages/gasket-plugin-nextjs/test/webpack-config.test.js @@ -10,6 +10,8 @@ describe('webpackConfigHook', () => { let mockGasket, mockWebpackConfig, mockContext; beforeEach(() => { + tryResolve.mockImplementation((moduleName) => moduleName); + mockGasket = { config: { root: '/path/to/app' @@ -46,12 +48,26 @@ describe('webpackConfigHook', () => { expect(result.resolve.alias).toEqual(expect.objectContaining({ [target]: false })); }); - it('adds empty alias for gasket file in client', () => { + it('adds empty alias for gasket.js file in client', () => { tryResolve.mockReturnValue(mockFilename); const result = webpackConfig(mockGasket, mockWebpackConfig, mockContext); expect(result.resolve.alias).toEqual(expect.objectContaining({ [mockFilename]: false })); }); + it('adds empty alias for expected default filenames', () => { + const mjsFilename = '/path/to/app/gasket.mjs'; + tryResolve.mockReturnValue(mjsFilename); + const result = webpackConfig(mockGasket, mockWebpackConfig, mockContext); + expect(result.resolve.alias).toEqual(expect.objectContaining({ [mjsFilename]: false })); + }); + + it('adds empty alias for gasket.ts file in client', () => { + const tsFilename = '/path/to/app/gasket.ts'; + tryResolve.mockReturnValue(tsFilename); + const result = webpackConfig(mockGasket, mockWebpackConfig, mockContext); + expect(result.resolve.alias).toEqual(expect.objectContaining({ [tsFilename]: false })); + }); + it('adds validateNoGasketCore to externals for client', () => { const result = webpackConfig(mockGasket, mockWebpackConfig, mockContext); expect(result.externals[0]).toBe(validateNoGasketCore);