Giter VIP home page Giter VIP logo

Comments (6)

acrazing avatar acrazing commented on September 27, 2024 1

If you use webpack to bundle your project with es module tree shaking(use .mjs files), you may need to add the following configurations:

// webpack.config.ts
export default {
  // ...
  resolve: {
      extensions: ['.ts', '.tsx', '.jsx', '.mjs', '.js', '.json'],
  },
  module: {
    rules: [
        { test: /\.mjs$/, type: 'javascript/auto' },
        // ...
    ],
  }
}

from mobx-sync.

pdeva avatar pdeva commented on September 27, 2024

can you explain what exactly is the rule doing?
i dont see any .mjs files in the source tree. what are they?

from mobx-sync.

acrazing avatar acrazing commented on September 27, 2024

Because I added module as lib/index.mjs in package.json, and webpack will use it to find out the es module entry rather than main(lib/index.js) as commonjs module.

from mobx-sync.

acrazing avatar acrazing commented on September 27, 2024

use extensions .mjs and .js rather than use two directories cjs and esm is for we can import mjs and cjs modules in same format like this:

import { parseStore } from 'mobx-sync/lib/parse-store'

from mobx-sync.

acrazing avatar acrazing commented on September 27, 2024

You can try timarney/react-app-rewired to customize your webpack config without ejecting.

from mobx-sync.

Venryx avatar Venryx commented on September 27, 2024

Just wanted to mention that the Webpack changes suggested above by acrazing worked for me.

Would be nice if there were a solution to this that doesn't require a change to one's Webpack config, but from @acrazing's commentary here, it seems that could be tricky.

from mobx-sync.

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.