Skip to content

Commit

Permalink
fix: default exclude gasket.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
agerard-godaddy committed Jan 22, 2025
1 parent 6e800b3 commit 7acee34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/gasket-plugin-nextjs/lib/webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
18 changes: 17 additions & 1 deletion packages/gasket-plugin-nextjs/test/webpack-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('webpackConfigHook', () => {
let mockGasket, mockWebpackConfig, mockContext;

beforeEach(() => {
tryResolve.mockImplementation((moduleName) => moduleName);

mockGasket = {
config: {
root: '/path/to/app'
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7acee34

Please sign in to comment.