Repository navigation
Replies: 17 comments 6 replies
|
I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it. |
|
Any progress on this? |
|
Strongly inspired by this project but use as input an arraybuffer this project is es6-module: https://github.com/cheminfo/arraybuffer-xml-parser |
|
@ramykl The current library has typing and can be used in TypeScript or or node js modules. Is there anything I'm missing that you're looking for? |
|
closing this issue. please reopen is you still find its not working |
|
What's still missing is an ESM for this package so that it can be packaged and optimized with packagers like webpack. For example, if you try to package fast-xml-parser with Angular 12, you get this warning. Warning: C:\Users\jfailenschmid\Documents\projects\workcopy\Kika\ng\webapps\projects\acesis\core\src\lib\shared\xml\xml-conversion.service.ts depends on 'fast-xml-parser'. CommonJS or AMD dependencies can cause optimization bailouts. @amitguptagwl I do not have the permission to reopen this issue, because I authored it but am not considered a collaborator. |
|
It's not difficult to transform but I'm just wondering can it cause issue to the people who are still on node js old version.🤔 |
|
Let me try to improve code to reduce bundle size within common js first |
|
So I've checked the whole code. FXP doesn't depend on any 3rd party module or even node js module that can be optimized to import particular functionality. So even if we transform this library in ECMAScript module, there is no size benefit. I would be happy to know if you want to highlight the problem with some example in case of FXP. |
|
I've checked the FXP code before and concluded that there is currently no other dependency. Therefore, I currently suppress the warning by Webpack by listing FXP as However, it would be better if FXP was also available/marked as ESM in addition to Common JS module. Maybe you could publish FXP both ways? If I recall correctly, Node JS supports ESM now, but I don't recall in which release (v17?) A lot of JS packages will continue to use Common JS, most likely for a long time, therefore, not supporting Common JS for FXP is probably not an option. |
|
The only solution I see here is to create another package like "fxp-esm" and updating it using some scripts on regular basis. |
|
You can distribute ESM and CJS to one "hybrid" package, this is an example: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html. |
|
I've converted the fxp to esm compatible and pushed the changes to a new branch I tried above approach. But, ts compiler as suggested in the link in above comment is throwing multiple errors related to syntax. I believe it is expecting to write ts files instead of esm module files. |
|
Any news on this topic? I check the |
|
Not to add another +1, but it would be nice to have this module available as an ESM module. This can be accomplished multiple ways and it would look something like: // package.json
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
"types": "./dist-types/index.d.ts",
"exports": {
".": {
"import": "./dist-es/index.js",
"require": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts"
}
}Then using tsup (as an example), you can build to both CJS & ESM using a simple config such as: export default defineConfig({
entry: ['src/fxp.ts'],
splitting: true,
sourcemap: true,
format: ['esm', 'cjs'],
clean: true,
dts: true
});But that would first require migrating the code base to Typescript. (Which should be possible by just changing the extensions to |
|
Do we have a esm version available now ? |
|
Done. published v5 to support ESM. plan for v5 is postponed to v6. |
Uh oh!
There was an error while loading. Please reload this page.
Checklist
Input
Would you like to work on this issue?
Bookmark this repository for further updates.
Please provide an ECMAScript module.
CommonJS modules cannot be optimized with webpack, for example, and the bundle size of the application is potentially larger.
As of Angular 10, a warning is emitted when building an app that imports
fast-xml-parser.All reactions