GithubHelp home page GithubHelp logo

Comments (6)

ahabhgk avatar ahabhgk commented on September 22, 2024 2

Yes, output.library.type = 'commonjs-static' should already fixed in the main branch, the fix will be released in v0.7.0

and @JSerFeng will fix the mangleExports soon, should also be released in v0.7.0

from rspack.

LingyuCoder avatar LingyuCoder commented on September 22, 2024

Seems to be a bug of optimization.mangleExports, cc @JSerFeng

should use info.used_name here?

from rspack.

psYifanChen avatar psYifanChen commented on September 22, 2024

@LingyuCoder
Btw, I also tried to output files in cjs but failed.
I can not get something like module.exports = { t as hello }; but only an IIFE.
Could you give me an example for how to configure rspack to output files in cjs in library mode?

from rspack.

LingyuCoder avatar LingyuCoder commented on September 22, 2024

@LingyuCoder Btw, I also tried to output files in cjs but failed. I can not get something like module.exports = { t as hello }; but only an IIFE. Could you give me an example for how to configure rspack to output files in cjs in library mode?

try to set output.library.type = "commonjs2" like:

/** @type {import("@rspack/core").Configuration} */
module.exports = {
  output: {
    library: {
      type: "commonjs2"
    }
  },
};

from rspack.

psYifanChen avatar psYifanChen commented on September 22, 2024

@LingyuCoder
Thanks! I got what I want by setting output.library.type to commonjs2 or commonjs.

But I found another diff which may be a bug.
When setting output.library.type to commonjs-static, there is a diff like this.

// v0.5.9
var r = n('294');
(exports.handler = r.handler), Object.defineProperty(exports, '__esModule', { value: !0 });

// v0.6.5
n('294'),
Object.defineProperty(exports, '__esModule', { value: !0 });

Just reporting.

from rspack.

LingyuCoder avatar LingyuCoder commented on September 22, 2024

@LingyuCoder Thanks! I got what I want by setting output.library.type to commonjs2 or commonjs.

But I found another diff which may be a bug. When setting output.library.type to commonjs-static, there is a diff like this.

// v0.5.9
var r = n('294');
(exports.handler = r.handler), Object.defineProperty(exports, '__esModule', { value: !0 });

// v0.6.5
n('294'),
Object.defineProperty(exports, '__esModule', { value: !0 });

Just reporting.

cc @ahabhgk , relate to full aligning library bootstrap with webpack

from rspack.

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.