Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '@rollup/plugin-esm-shim' #123

Merged
merged 8 commits into from
Nov 11, 2023
Merged

Add '@rollup/plugin-esm-shim' #123

merged 8 commits into from
Nov 11, 2023

Conversation

Peeterush
Copy link
Contributor

A new attempt at getting both ESM and UMD builds to play well!

@Peeterush
Copy link
Contributor Author

Ah, Deno is like that one dentist.

I made a PR to @rollup/plugin-esm-shim to add the prefix that Deno is asking for.

@Peeterush
Copy link
Contributor Author

Edit: added a test for dist files like suggested by iambumblehead.

const wasmLocation = '../../node_modules/@dlemstra/magick-native/magick.wasm';

initializeImageMagick(wasmLocation).then(() => {
console.log(Magick.imageMagickVersion);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use the features here instead so we don't need a regex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@dlemstra
Copy link
Owner

dlemstra commented Nov 5, 2023

Can we avoid using that module if magick-native would provide a magick.js and magick.mjs file? There is a build option in emscripten sdk to create a ES6 module. How should I package those files in a package.json file? I am now using this file: https://github.com/dlemstra/Magick.Native/blob/main/publish/wasm/package.json.

@Peeterush
Copy link
Contributor Author

ESM would be better yes! Vite would only use the ESM if it's available, so no CJS version needed. Package should look something like this:

{
    "name": "@dlemstra/magick-native",
    "version": "",
    "type": "module",
    "exports": {
        ".": {
            "types": "./index.d.ts",
            "default": "./index.js",
        },
    },
    "module": "./index.js",
    "types": "./index.d.ts",
    "repository": {
        "type": "git",
        "url": "git+https://github.com/dlemstra/Magick.Native.git",
    },
    "author": "Dirk Lemstra",
    "license": "Apache-2.0",
    "files": [
        "./index.d.ts",
        "./index.js",
        "magick.wasm",
        "NOTICE",
    ],
}

Note: because of "type": "module", any .js is assumed to be ESM, so no .mjs needed.

@Peeterush
Copy link
Contributor Author

Also; my PR to @rollup/plugin-esm-shim has been accepted and published, so Deno is happy now!

@dlemstra
Copy link
Owner

dlemstra commented Nov 7, 2023

Do we still need the @rollup/plugin-esm-shim once Magick.Native has switched to ESM?

@dlemstra
Copy link
Owner

dlemstra commented Nov 8, 2023

I have made some changes to the Magick.Native build but I did not rename the files. Can you check if that works? You can use version 0.202311.80706 for this.

@dlemstra dlemstra merged commit 13eb00a into dlemstra:main Nov 11, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants