Skip to content

Conversation

@colinmurphy
Copy link
Member

@colinmurphy colinmurphy commented Mar 25, 2025

Tasks

  • I have signed a Contributor License Agreement (CLA) with WP Engine.
  • If a code change, I have written testing instructions that the whole team & outside contributors can understand.
  • I have written and included a comprehensive changeset to properly document the changes I've made.

Description

Fixes #2073

A very odd issue with when you run the code below, the first line of the next.config.js is missing so you get an error saying
withFaust is not defined... as the first line const { withFaust, getWpHostname } = require('@faustwp/core'); is removed.

npx create-next-app \
    -e https://github.com/wpengine/faustjs/tree/canary \
    --example-path examples/next/tutorial \
    --use-npm

The fix was to switch the first two lines around as I think maybe when we install npm packages, the first line above createSecureHeaders is being removed.

Related Issue(s):

#2073

Testing

npx create-next-app \    
    -e https://github.com/wpengine/faustjs/tree/bug/fix-faust-tutorial-with-faust-not-defined \
    --example-path examples/next/tutorial \
    --use-npm

and then output the file

cat my-app/next.config.js 
const { createSecureHeaders } = require('next-secure-headers');
const { withFaust, getWpHostname } = require('@faustwp/core');

/**
 * @type {import('next').NextConfig}
 **/
module.exports = withFaust({
	reactStrictMode: true,
	sassOptions: {
		includePaths: ['node_modules'],
	},
	images: {
		domains: [getWpHostname()],
	},
	async headers() {
		return [
			{
				source: '/:path*',
				headers: createSecureHeaders({
					xssProtection: false,
				}),
			},
		];
	},
});

Followed the rest of the tutorial and I was able to get npm run dev to work - https://faustjs.org/docs/tutorial/learn-faust/

Screenshots

Screenshot 2025-03-25 at 11 00 45 Screenshot 2025-03-25 at 11 00 54

Issue whereby some users are missing the first line of next.config.js
… issue with the first line of code being removed when running npx.
@changeset-bot
Copy link

changeset-bot bot commented Mar 25, 2025

⚠️ No Changeset found

Latest commit: 3034b39

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

📦 Next.js Bundle Analysis for @faustwp/getting-started-example

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@colinmurphy colinmurphy marked this pull request as ready for review March 25, 2025 11:02
@colinmurphy colinmurphy requested a review from a team as a code owner March 25, 2025 11:02
@moonmeister moonmeister merged commit f01f0a7 into canary Mar 26, 2025
18 checks passed
@moonmeister moonmeister deleted the bug/fix-faust-tutorial-with-faust-not-defined branch March 26, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants