8000 Quantum not working well with variables named "require" inside AngularJS code · Issue #1142 · fuse-box/fuse-box · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Quantum not working well with variables named "require" inside AngularJS code #1142
Closed
@valepu

Description

@valepu

Greetings,
I'm having an issue very similar to this one: #1133
In AngularJS (1.6.9) there is this piece of code:

[...]
    function getControllers(directiveName, require, $element, elementControllers) {
      var value;

      if (isString(require)) {
        var match = require.match(REQUIRE_PREFIX_REGEXP);
        var name = require.substring(match[0].length);
[...]

Which doesn't get parse correctly when using quantum.

Error: ReferenceError: require is not defined

Converted code (without uglify):

function getControllers(directiveName, $fsx, $element, elementControllers) {
                    var value;
                    if (isString($fsx)) {
                        var match = require.match(REQUIRE_PREFIX_REGEXP);
                        var name = require.substring(match[0].length);

Reading the issue linked above i updated fusebox to 3.2.0-next10 but then something similar happened to another piece of code in AngularJS:

AngularJS code:

  function getDirectiveRequire(directive) {
    var require = directive.require || (directive.controller && directive.name);

    if (!isArray(require) && isObject(require)) {
      forEach(require, function(value, key) {
        var match = value.match(REQUIRE_PREFIX_REGEXP);
        var name = value.substring(match[0].length);
        if (!name) require[key] = match[0] + key;
      });
    }

Error: TypeError: e.match is not a function

Converted code (without uglify):

function getDirectiveRequire(directive) {
            var require = directive.require || directive.controller && directive.name;
            if (!isArray($fsx) && isObject($fsx)) {
                forEach($fsx, function (value, key) {
                    var match = value.match(REQUIRE_PREFIX_REGEXP);
                    var name = value.substring(match[0].length);
                    if (!name)
                        require[key] = match[0] + key;
                });
            }
            return $fsx;
        }

This is my quantum configuration (i have tried with any combination of replaceTypeOf and mangle, also completely disabling uglify, still not working)


				this.isProduction && QuantumPlugin({
					//bakeApiIntoBundle: "app",
					replaceTypeOf: false,
					treeshake: true,
					uglify: {
						mangle: true
					},
					css: {
						clean: true
					},
					api: core => {
						core.solveComputed("moment/moment.js", {
							mapping: "moment/locale**",
							fn: statement => {
                                                             statement.setExpression(`"moment/locale/" + name + ".js"`);
							}
						});
					}
					// containedAPI : true
				})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions