Docx: Error while serving and building in angular application

Created on 3 Jan 2020  路  13Comments  路  Source: dolanmiu/docx

I am trying to use this library in angular application. It was working fine for 5.0.0-Rc7. After updating to stable release 5.0.0, I am encountering errors while serving and building the application. Below is the error that is produced while serving the application.

error

I think the reference for types of node is missing and the declaration file for style-options is also missing.

bug

Most helpful comment

ill make a hot fix, weird

All 13 comments

ill make a hot fix, weird

ill make a hot fix, weird

Any update on this?

I am also facing issues after migrating Docx from version 4 to 5 in angular application

I am facing same issue after upgrading to stable release 5.0.0

I am also facing the same issue after upgrading from 5.0.0-Rc7 version to release 5.0.0 .
Eagerly waiting for the fix as soon as possible.

I have made a fix here:

https://github.com/dolanmiu/docx/pull/490

This correctly exports the style-options, which should fix the problem you're having

It also adds @types/node as a dependency, so it will include all that Buffer good stuff included, which should fix that other issue

Will be released in 5.0.1

Still not working - file is not provided.
Its related to: https://github.com/s-panferov/awesome-typescript-loader/issues/432

Please add:

/**
 * @ignore
 */
export const WORKAROUND = "";

to style-options.ts like in other files which contains only declarations or switch to ts-loader.

@dolanmiu The solution by @webcarrot works for the style-options.ts.
For the missing type for the Buffer from node, it is still not working. I checked the distribution build and
/// <reference types="node" />
is missing from the declaration files which is present in previous builds.

packer.d.ts

Previous releases:
/// <reference types="node" />
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}

Current release:
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}

Fixed in 5.0.2

Read more about it here:

https://github.com/dolanmiu/docx/issues/492

@dolanmiu The solution by @webcarrot works for the style-options.ts.
For the missing type for the Buffer from node, it is still not working. I checked the distribution build and
/// <reference types="node" />
is missing from the declaration files which is present in previous builds.

packer.d.ts

Previous releases:
/// <reference types="node" />
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}

Current release:
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}

Interesting... Can you tell me which version worked? So I can investigate?

@c-bibek-shrestha

Edit: 5.0.0-Rc7 am I correct?

Here is the diff between master and 5.0.0-rc7:

https://github.com/dolanmiu/docx/compare/5.0.0-rc7...master?diff=split

here is the diff between master and 5.0.0-rc6:

https://github.com/dolanmiu/docx/compare/5.0.0-rc6...master?diff=split

I can't see anything suspecious

Just confirmed it working on a stack-blitz:

https://stackblitz.com/edit/angular-afvxtz

Can close

@dolanmiu The solution by @webcarrot works for the style-options.ts.
For the missing type for the Buffer from node, it is still not working. I checked the distribution build and
/// <reference types="node" />
is missing from the declaration files which is present in previous builds.

packer.d.ts

Previous releases:
/// <reference types="node" />
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}
Current release:
import { File } from "../../file";
export declare class Packer {
static toBuffer(file: File, prettify?: boolean): Promise<Buffer>;
static toBase64String(file: File, prettify?: boolean): Promise<string>;
static toBlob(file: File, prettify?: boolean): Promise<Blob>;
private static readonly compiler;
}

Interesting... Can you tell me which version worked? So I can investigate?

@c-bibek-shrestha

Edit: 5.0.0-Rc7 am I correct?

Yes. I was talking about the *.d.ts file that is generated after you build it. Now it works after including types:["node"] in tsconfig.app.json. Kudos for the library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesmontalvo3 picture jamesmontalvo3  路  5Comments

zeco2309 picture zeco2309  路  5Comments

sleepinzombie picture sleepinzombie  路  3Comments

jacwright picture jacwright  路  6Comments

madarche picture madarche  路  5Comments