-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fail to bundle when using Rollup for esm libraries in browser environment #32430
Comments
@jeremymeng Could you help investigate the bundling issue? We tried the webpack steps and it succeeded. but for tool rollup we failed with above message. |
@jeremymeng It works for |
@v-jiaodi interesting! Can you look at the Sources tab of your browser and show where Oh I DID make some changes to the pet store client by add diff --git a/petstore/clients/javascript/package.json b/petstore/clients/javascript/package.json
index ac5cb12..8f3deda 100644
--- a/petstore/clients/javascript/package.json
+++ b/petstore/clients/javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "@unbranded/petstore",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"description": "A generated SDK for PetStoreClient.",
"engines": {
"node": ">=18.0.0"
@@ -277,6 +277,11 @@
}
}
},
+ "files": [
+ "dist/",
+ "README.md",
+ "LICENSE"
+ ],
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js" |
@v-jiaodi I updated the bundling samples in the same PR. If you are still having issues please share a repro project. |
@jeremymeng The same issue still exists for |
@v-jiaodi I made some changes to your project and was able to build for parcel/js. There was some error in the first build (known issue) but second build is green. I did not see the same error as the one in your screenshot. diff --git a/parcel/js/index.html b/parcel/js/index.html
index a4bba5f..9126607 100644
--- a/parcel/js/index.html
+++ b/parcel/js/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Azure SDK Storage Example</title>
- <script src="index.js"></script>
+ <script type="module" src="index.js"></script>
</head>
<body>
<h1>Azure SDK Storage Example</h1>
diff --git a/parcel/js/index.js b/parcel/js/index.js
index 9900ea0..17eb532 100644
--- a/parcel/js/index.js
+++ b/parcel/js/index.js
@@ -1,16 +1,16 @@
-const { PetStoreClient } = require("@unbranded/petstore");
+import { PetStoreClient } from "@unbranded/petstore";
const client = new PetStoreClient("http://localhost:5118", {
diff --git a/parcel/js/package.json b/parcel/js/package.json
index 1ce6673..40a63a2 100644
--- a/parcel/js/package.json
+++ b/parcel/js/package.json
@@ -2,7 +2,6 @@
"name": "example",
"version": "1.0.0",
"description": "",
- "main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}, Result:
|
@MaryGao @jeremymeng Double checked and found that the same error still occurred with the above changes. I'm not sure if it's my environmental issue. |
Desciption: fail to bundle when using Rollup for esm libraries in browser environment.
Repro steps:
rollup --config
, get error as follow:rollup --config --bundleConfigAsCjs
according to the prompt successfully. But when accessed from a browser, the following error occurs:The text was updated successfully, but these errors were encountered: