Edward
Edward

Reputation: 30046

Office Addin fail to load after swtiching to sharedruntime

I followed Configure your Office Add-in to use a shared JavaScript runtime to configure shared runtime for excel addin.

But, it fail to load

Here is my manifest.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
  <Id>f9459a58-57de-4427-9db6-b90ef7a6eb6c</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Meekou.ExcelAddIn"/>
  <Description DefaultValue="Write your own Excel functions in TypeScript."/>
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
  <SupportUrl DefaultValue="https://www.contoso.com/help"/>
  <AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Workbook"/>
  </Hosts>
  <Requirements>
    <Sets DefaultMinVersion="1.1">
      <Set Name="SharedRuntime" MinVersion="1.1"/>
    </Sets>
  </Requirements>
  <DefaultSettings>
    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
  </DefaultSettings>
  <Permissions>ReadWriteDocument</Permissions>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Workbook">
        <Runtimes>
          <Runtime resid="Taskpane.Url" lifetime="long" />
        </Runtimes>
        <AllFormFactors>
          <ExtensionPoint xsi:type="CustomFunctions">
            <Script>
              <SourceLocation resid="Functions.Script.Url"/>
            </Script>
            <Page>
              <SourceLocation resid="Taskpane.Url"/>
            </Page>
            <Metadata>
              <SourceLocation resid="Functions.Metadata.Url"/>
            </Metadata>
            <Namespace resid="Functions.Namespace"/>
          </ExtensionPoint>
        </AllFormFactors>
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="GetStarted.Title"/>
            <Description resid="GetStarted.Description"/>
            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <FunctionFile resid="Taskpane.Url"/>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <OfficeTab id="TabHome">
              <Group id="CommandsGroup">
                <Label resid="CommandsGroup.Label"/>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Control xsi:type="Button" id="TaskpaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ExecuteFunction">
                    <FunctionName>action</FunctionName>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Functions.Script.Url" DefaultValue="https://localhost:3000/dist/functions.js"/>
        <bt:Url id="Functions.Metadata.Url" DefaultValue="https://localhost:3000/dist/functions.json"/>
        <bt:Url id="Functions.Page.Url" DefaultValue="https://localhost:3000/dist/functions.html"/>
        <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
        <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
        <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="Functions.Namespace" DefaultValue="Meekou"/>
        <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
        <bt:String id="CommandsGroup.Label" DefaultValue="Commands Group"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the HOME tab and click the 'Show Taskpane' button to get started."/>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

Here is the error

Compiled with problems:X

Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\taskpane\taskpane.ts(37,34)
      TS2304: Cannot find name 'add'.



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\taskpane\taskpane.ts(38,34)
      TS2552: Cannot find name 'logMessage'. Did you mean 'onmessage'?



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\commands\commands.ts(38,34)
      TS2304: Cannot find name 'add'.



Error:

[tsl] ERROR in C:\Users\edward\Meekou\Meekou\Meekou.ExcelAddIn\src\commands\commands.ts(39,34)
      TS2552: Cannot find name 'logMessage'. Did you mean 'onmessage'?


Upvotes: 3

Views: 529

Answers (2)

Eric Guesdon
Eric Guesdon

Reputation: 1

I met the same issue. I solved it by changing instructions within webpack.config.js.

// ========= I changed this ========= \

<pre>
const config = {
    devtool: "source-map",
    entry: {
      polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
      <b>functions: "./src/functions/functions.ts",</b>
      taskpane: "./src/taskpane/taskpane.ts",
      commands: "./src/commands/commands.ts",
},
</pre>

// ============ With this ============= \

Everything has worked well when i changed the instruction order. Put "functions" after "taskpane".

<pre>
const config = {
    devtool: "source-map",
    entry: {
      polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
      taskpane: "./src/taskpane/taskpane.ts",
      commands: "./src/commands/commands.ts",
      <b>functions: "./src/functions/functions.ts",</b>
},
</pre>

my webpack version is 5.74.0

Hope this will help you.

Regard

Upvotes: 0

Rundong-MSFT
Rundong-MSFT

Reputation: 109

I cannot repro your issue. Your manifest looks all right.

From top of my mind, the error message should be related to "CustomFunctionsMetadataPlugin" (it would be called during npm run build).

Before compile ".ts" to ".js", the plugin "CustomFunctionsMetadataPlugin" would add "associate" logic (CustomFunctions.associate("ADD", add)) to the input file (e.g. src\functions\functions.ts).

From the error message, I guess maybe "CustomFunctionsMetadataPlugin" performed the above steps incorrectly in your side. You can try to add "associate" logic manually to see if the issue is resolved.

You can also share the compiled file (dist\function.js), so that I can help to make a further check.

Thanks,

Rundong

Upvotes: -1

Related Questions