Skip to content

Transition from gulp to heft with polyfillsΒ #10538

@JamesDerrickHH

Description

@JamesDerrickHH

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

πŸ’₯ SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • πŸ’₯ Internet Explorer
  • πŸ’₯ Microsoft Edge
  • πŸ’₯ Google Chrome
  • πŸ’₯ FireFox
  • πŸ’₯ Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • spfx v1.22.1

Issue description

Hi, just looking to get some advice, I'm taking a first look at upgrading a webpart from an older version of spfx to the latest, meaning I'm transitioning from gulp to heft.
My solution's gulpfile includes a fair few polyfills and I cannot work out how to get the same behaviour in heft. I'm assuming I need a heft.json file in my config folder but beyond that I'm very confused.
This was my gulpfile

'use strict';

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

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;
};

build.configureWebpack.mergeConfig({
  additionalConfiguration: (generatedConfiguration) => {
    generatedConfiguration.module.rules.push(
      {
        resolve: {
          fallback: {
            fs: require.resolve("graceful-fs"),
            stream: require.resolve("stream-browserify"),
            path: require.resolve("path-browserify"),
            buffer: require.resolve("buffer"),
            crypto: false,
            constants: false,
            util: false,
            child_process: false,
            assert: false
          }
        }
      }
    );

    generatedConfiguration.plugins.push(
      new webpack.ProvidePlugin({
        process: "process/browser",
        Buffer: ["buffer", "Buffer"]
      }),
      new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
        const mod = resource.request.replace(/^node:/, "");
        switch (mod) {
            case "path":
                resource.request = "path";
                break;
            case "fs":
                resource.request = "fs";
                break;
            case "buffer":
                resource.request = "buffer";
                break;
            case "stream":
                resource.request = "readable-stream";
                break;
            default:
                throw new Error(`Not found ${mod}`);
        }
      }),
    )

    return generatedConfiguration;
  }
});

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

Any bit of guidance would be greatly appreciated

Metadata

Metadata

Assignees

Labels

Needs: Author FeedbackAwaiting response from the original poster of the issue. Marked as stale if no activity for 7 days.sharepoint-developer-supportsharepoint-developer-support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions