Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build script Babel Polyfill-exclusions not found #65479

Closed
2 tasks done
djcowan opened this issue Sep 19, 2024 · 7 comments
Closed
2 tasks done

build script Babel Polyfill-exclusions not found #65479

djcowan opened this issue Sep 19, 2024 · 7 comments
Labels
[Type] Bug An existing feature does not function as intended

Comments

@djcowan
Copy link
Contributor

djcowan commented Sep 19, 2024

Description

While running @wordpress/scripts we are receiving an error when calling start or build

  • `[BABEL]: Cannot find module './polyfill-exclusions'
    current package dev/dependencies:
  1. "@wordpress/interactivity": "^6.8.0"
  2. "@wordpress/scripts": "^30.0.0",
  3. "typescript": "^5.5.4"
  4. update to op - "@wordpress/url": "^4.8.0"

Step-by-step reproduction instructions

The plugin uses a viewModuleScript and interactivity: true

  1. in plugin root - run script "packages-update": "wp-scripts packages-update"
  2. run "wp-scripts build --experimental-modules", or "wp-scripts build",

We will continue to review our setup

Screenshots, screen recording, code snippet

ERROR in ./src/dialog/view.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL]: Cannot find module './polyfill-exclusions'
Require stack: 

our tsconfig

{
	"$schema": "https://json.schemastore.org/tsconfig.json",
	"compilerOptions": {
		"forceConsistentCasingInFileNames": true,
		"allowJs": true,
		"checkJs": true,
		"allowSyntheticDefaultImports": true,
		"jsx": "preserve",
		"target": "esnext",
		"module": "esnext",
		"lib": [
			"DOM",
			"DOM.Iterable",
			"ESNext"
		],
		"declaration": true,
		"declarationMap": true,
		"composite": true,
		"emitDeclarationOnly": true,
		"isolatedModules": true,
		"skipDefaultLibCheck": true,
		/* Strict Type-Checking Options */
		"strict": true,
		/* Additional Checks */
		"noImplicitReturns": true,
		"noFallthroughCasesInSwitch": true,
		/* Module Resolution Options */
		"moduleResolution": "node",
		/* This needs to be false so our types are possible to consume without setting this */
		"esModuleInterop": false,
		"resolveJsonModule": true,
		"typeRoots": [
			"./node_modules/@types"
		],
		"types": []
	},
	"include": [
		"./src",
		"./src/*"
	],
	"exclude": [
		"**/*.android.js",
		"**/*.ios.js",
		"**/*.native.js",
		"**/benchmark",
		"packages/*/build-*/**",
		"packages/*/build/**",
		"**/test/**",
		"packages/**/react-native-*/**"
	]
}

Environment info

Gutengerg Version 19.2.0
package versions as listed
NB unable to confirm:
Please confirm that you have tested with all plugins deactivated except Gutenberg.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@djcowan djcowan added the [Type] Bug An existing feature does not function as intended label Sep 19, 2024
@gregdev
Copy link

gregdev commented Sep 19, 2024

I'm guessing this is related to #65292

@djcowan
Copy link
Contributor Author

djcowan commented Sep 19, 2024

thanks will read.
update
I have just run a fresh create-block. But I'm running in a dev container which might be tainted.
Will exit and run again on bare metal.

npx @wordpress/create-block@latest todo-list
Need to install the following packages:
@wordpress/create-block@4.51.0
// ...

./src/index.js 39 bytes [built] [code generated] [1 error]

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL]: Cannot find module './polyfill-exclusions'

@djcowan djcowan closed this as completed Sep 19, 2024
@gregdev
Copy link

gregdev commented Sep 19, 2024

@djcowan it looks like there are two files, polyfill-exclusions.js and replace-polyfills.js, that are missing from the @wordpress/babel-preset-default package. As a local workaround you can comment out lines 9-10 from node_modules/@wordpress/babel-preset-default/index.js until a fix is released.

@namjul
Copy link

namjul commented Sep 19, 2024

I think this is still an issue.

In https://github.com/WordPress/gutenberg/pull/65292/files @wordpress/babel-preset-default got 2 new files like polyfill-exclusions.js.
But it's missing in the published version https://www.npmjs.com/package/@wordpress/babel-preset-default?activeTab=code.

We might want to add these to package.json fields .

@gregdev
Copy link

gregdev commented Sep 19, 2024

Actually for a better workaround: specifying your own babel config file will prevent WordPress from providing its own configuration, so the @wordpress/babel-preset-default package won't be loaded.

In my project I've created a .babelrc.js file which seems to work for my purposes:

const { hasArgInCLI } = require('@wordpress/scripts/utils')

const isProduction = process.env.NODE_ENV === 'production'
const hasReactFastRefresh = hasArgInCLI('--hot') && !isProduction

module.exports = {
    presets: [require.resolve('@babel/preset-typescript')],
    plugins: [
        require.resolve('@wordpress/warning/babel-plugin'),
        [
            require.resolve('@babel/plugin-transform-react-jsx'),
            {
                runtime: 'automatic',
            },
        ],
        hasReactFastRefresh && require.resolve('react-refresh/babel'),
    ].filter(Boolean),
}

@djcowan
Copy link
Contributor Author

djcowan commented Sep 19, 2024

Thank you @gregdev for looking into the issue and for providing a useful patch. Greatly appreciated.
@namjul - thank you for confirming the issue. I closed the ticket after being made aware of #65292
I could not be sure the issue was not the result of a local misconfiguration

@sirreal
Copy link
Member

sirreal commented Sep 19, 2024

An updated version of the affected packages has been released so this issue should be addressed without requiring workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants