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

[js/web] allow bundler import condition for not bundling wasm #24014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Mar 12, 2025

Description

This gives a way for webapp developers to customize the bundler behavior regarding whether to bundle the wasm.

To avoid treating ort-wasm-threaded-simd.jsep.mjs and ort-wasm-threaded-simd.jsep.wasm as dependencies during the process of bundler build, use import condition onnxruntime-web-use-extern-wasm.

For webpack:

module.exports = {
  //...
  resolve: {
    conditionNames: ['onnxruntime-web-use-extern-wasm', 'import', 'module'],
  },
};

For esbuild:

await esbuild.build({
  //...
  conditions: ['onnxruntime-web-use-extern-wasm', 'import', 'module'],
})

For rollup:

import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
  //...
  plugins: [nodeResolve({
    exportConditions: ['onnxruntime-web-use-extern-wasm', 'import', 'module', 'development|production']
  })]
};

Motivation and Context

@fs-eire
Copy link
Contributor Author

fs-eire commented Mar 12, 2025

Unfortunately, I didn't figure out a solution that allows bundler to achieve this without needing to modify any user code (bundler config).

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.

1 participant