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

[BUG/QUESTION] MGT People Picker does not work with SPFx 1.19.0 #3333

Open
vishalshitole opened this issue Oct 16, 2024 · 3 comments
Open

[BUG/QUESTION] MGT People Picker does not work with SPFx 1.19.0 #3333

vishalshitole opened this issue Oct 16, 2024 · 3 comments
Labels
bug Something isn't working Needs: Triage 🔍

Comments

@vishalshitole
Copy link

Describe the bug
We are using MGT People Picker control in our SPFx solution. Per Microsoft documentation, we have added required configurations in gulpfile.js and package.json. It worked fine with SPFx version 1.18.2. But, when we upgraded our solution to SPFx version 1.19.0, it started giving runtime error as shown in the following screenshot.

image

[!NOTE] Please note that the SPFx solution builds and bundles perfectly fine, but only fails at runtime when web part is added/executed on page. Also, as you can see in the above screenshot, we do not get any specific error message, nor do we get any error in the browser console.

Expected behavior
MGT People Picker should work with SPFx 1.19.0

Environment (please complete the following information):

  • Browser: Edge, Chrome
  • Framework: SPFx 1.19.0 with React
  • Context: SharePoint Online

Additional context

[!IMPORTANT] We use pnpm as a package manager for our solutions.

Please find below our gulpfile.js with required configuration.

"use strict";

const build = require("@microsoft/sp-build-web");
const path = require("path");

build.addSuppression(
	`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`
);

var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
	var result = getTasks.call(build.rig);

	result.set("serve", result.get("serve-deprecated"));

	return result;
};

// add babel-loader and some transforms to handle es2021 language features which are unsupported in webpack 4 by default
const litFolders = [
	`node_modules${path.sep}.pnpm${path.sep}lit${path.sep}`,
	`node_modules${path.sep}.pnpm${path.sep}@lit${path.sep}`,
	`node_modules${path.sep}.pnpm${path.sep}lit-html${path.sep}`,
	`node_modules${path.sep}.pnpm${path.sep}lit-element${path.sep}`,
  `node_modules${path.sep}lit${path.sep}`,
	`node_modules${path.sep}@lit${path.sep}`,
	`node_modules${path.sep}lit-html${path.sep}`,
	`node_modules${path.sep}lit-element${path.sep}`,
];
build.configureWebpack.mergeConfig({
	additionalConfiguration: (generatedConfiguration) => {
		generatedConfiguration.module.rules.push({
			test: /\.js$/,
			// only run on lit packages in the root node_module folder
			include: (resourcePath) => litFolders.some((litFolder) => resourcePath.includes(litFolder)),
			use: {
				loader: "babel-loader",
				options: {
					plugins: [
						"@babel/plugin-transform-optional-chaining",
						"@babel/plugin-transform-nullish-coalescing-operator",
						"@babel/plugin-transform-logical-assignment-operators",
					],
				},
			},
		});
		return generatedConfiguration;
	},
});

build.initialize(require("gulp"));

Also, we have added following packages as dev dependencies in our package.json.

"@babel/plugin-transform-logical-assignment-operators": "^7.25.8",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.25.8",
"@babel/plugin-transform-optional-chaining": "^7.25.8",
"babel-loader": "8.3.0",
@vishalshitole vishalshitole added bug Something isn't working Needs: Triage 🔍 labels Oct 16, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Graph Toolkit Oct 16, 2024
@musale
Copy link
Contributor

musale commented Oct 17, 2024

hello @vishalshitole, I have been looking into this and put up pnp/mgt-samples#25 that:

  • removes the code that uses babel transforms on lit html files.
  • Updates SPFx to 1.20+

My understanding is that this code was put in to transform the lit files to handle es2021 language features which are unsupported in webpack 4 by default. However, on webpack v5+ this is not necessary. From v1.19 of SPFx webpack v5 is used. Therefore, this workaround isn't necessary.

Could you remove the code that transforms the lit files as well as the babel deps and retry?

@vishalshitole
Copy link
Author

@musale Thank you for your response.

I have tried removing the code that transforms the lit files and babel dependencies from my SPFx 1.19.0 solution. However, it still does not work and gives same error.

@musale
Copy link
Contributor

musale commented Oct 22, 2024

@vishalshitole the only difference here is you're using pnpm. Let me repro with that and circle back asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs: Triage 🔍
Projects
Status: Needs Triage 🔍
Development

No branches or pull requests

2 participants