Giter Club home page Giter Club logo

Comments (3)

DonTsipa avatar DonTsipa commented on June 9, 2024

Hey, just ran into this issue myself, it seems like in bundle there are both .js and .cjs files from this package. It can be a problem because of webpack / babel configuration, that forces to use commonjs instead of es6 modules.
I added "sideEffects": false to my package.json and it worked

But sideEffects can be tricky
By default Typescript uses CommonJs module resolution, so you can also set

"module": "ES2020",
 "target":"ES2020",
 "moduleResolution": "Bundler",

in your tsconfig.ts. It also will force to use only es6 module resolution
Related issue on ts-loader:
TypeStrong/ts-loader#886 (comment)

from webext-bridge.

VnUgE avatar VnUgE commented on June 9, 2024

Thank you for your response, I have been waiting to get some time to learn and play around. Tonight I have spent a few hours playing around with my tsconfig and Vite bundler settings, and nothing has changed unfortunately. I also tested setting "sideEffects":"false" in my package.json file. I always use "type":"module"

Here are my latest configurations maybe you might have some more insight

{
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "compilerOptions": {
    "target": "es2020",
    "useDefineForClassFields": true,
    "module": "es2020",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  }
}

And my vite.config.js build settings (I removed the server configs for brevity) I just added the build target value to vite for testing, but did not originally set it.

  plugins: [ vue() ],
  build: {
    cssCodeSplit: true,
    rollupOptions: {
      plugins: [],
    },
    target: "es2020",
  },
  optimizeDeps: {
    exclude: ['']
  },
  css: {
    postcss: postcss
  },

from webext-bridge.

VnUgE avatar VnUgE commented on June 9, 2024

So I have been messing around a bit more. I downloaded the latest master branch into my local source tree and built it locally.

I was able to do some more tracing.

Only when tracing, I can catch the following exceptions, and see the promise being rejected with the screenshot below. Without the debugger attached, the promises returned from sendMessage() never actually complete (resolve or reject). This type of JS behavior is new to me. I have to assume this is a bundler or browser related issue. I haven't found a silver bullet bundler/tsconfig setting yet. I removed all intervals/timers that may have been blocking the event loop somehow, no change.

trace message

Error message

from webext-bridge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.