SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.02k forks source link

Module not found: Error: Can't resolve '@ms/sp-telemetry' #9970

Open vishalshitole opened 1 month ago

vishalshitole commented 1 month ago

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

Additional environment details

Issue description

I have created a library of reusable code with Rollup, and published it to the private/internal NPM registry. When I try to use that library package in my SPFx solution, I get multiple 'Module not found' error messages while bundling/serving the solution. However, when I add @microsoft/sp-application-base package as a dependency in my SPFx project, it works fine. Please find the attached file with the error message JSON below.

module-not-found-error.json

Below is the rollup.config.js of my reusable code library.

import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import terser from "@rollup/plugin-terser";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import packageJson from './package.json';
import { visualizer } from "rollup-plugin-visualizer";

export default [
  {
    input: "src/index.ts",
    output: [
      {
        file: packageJson.main,
        format: "cjs",
        sourcemap: true,
      },
      {
        file: packageJson.module,
        format: "esm",
        sourcemap: true,
      },
    ],
    plugins: [
      peerDepsExternal(),
      resolve(),
      commonjs(),
      typescript({ tsconfig: "./tsconfig.json" }),
      terser(),
      visualizer(),
    ],
    external: [
      "@microsoft/sp-application-base",
      "@microsoft/sp-core-library",
      "@microsoft/sp-component-base",
      "@microsoft/sp-dynamic-data",
      "@microsoft/sp-http",
      "@microsoft/sp-page-context",
      "@microsoft/sp-webpart-base"
    ],
  },
  {
    input: 'src/index.ts',
    output: [{ file: "dist/types.d.ts", format: "es" }],
    plugins: [dts.default()],
  },
];

Not sure if I am missing anything here. Any inputs/guidance is greatly appreciated.

Thank you!