Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.
This repository was archived by the owner on Oct 17, 2020. It is now read-only.

Bundler failing with undefined dependency when a dynamic reference exists in a package #588

@julienmouraddotcom

Description

@julienmouraddotcom

Trying to use react-live module but with no success, I noticed that the bundler was creating an undefined package in one of the dependencies which was causing the react widget to fail. The widget was created using yo liferay-bundle.

Liferay.Loader.define('my-project$regexpu-core@4.7.0/rewrite-pattern', ['module', 'exports', 'require', 'my-project$regjsgen', 'my-project$regjsparser', 'my-project$regenerate', 'my-project$unicode-match-property-ecmascript', 'my-project$unicode-match-property-value-ecmascript', './data/iu-mappings', './data/character-class-escape-sets', 'my-project$undefined'], function (module, exports, require) {
...

Notice my-project$undefined at the end.

Browser log error:

Some information about the require() call follows:
   · Require call id: 1 
   · Required modules: ["my-project@1.0.0"] 
   · Missing modules: (n/a) 
   · Stack trace of the require() call: 
        Error
            at e.value (http://localhost:8080/o/frontend-js-web/loader/loader.js:1:5898)
 Error: The following problems where detected while resolving modules:
    · Missing dependency ':ERROR:Missing version constraints for my-project$undefined in package.json of my-project$regexpu-core@4.7.0' of 'my-project$regexpu-core@4.7.0/rewrite-pattern'

And this is from liferay-npm-bundler-report:

Failed to resolve dependency my-project$undefined with error: Error: Cannot find module 'undefined/package.json' from './node_modules/regexpu-core'

.npmbuildrc:

{
	"translatorTextKey": "",
	"supportedLocales": [],
	"liferayDir": "/Users/julienmourad/projects/bundles/liferay-dxp-7.2.10-dxp-4",
	"webpack": {
		"rules": [
			{
				"test": "src\\/.*\\.js$",
				"use": "babel-loader"
			}
		]
	}
}

.npmbundlerrc:

{
	"create-jar": {
		"output-dir": "dist",
		"features": {
			"js-extender": true,
			"web-context": "/my-project",
			"localization": "features/localization/Language",
			"configuration": "features/configuration.json"
		}
	},
	"dump-report": true
}

package.json:

"devDependencies": {
	"liferay-npm-bundler": "^2.8.0",
	"liferay-npm-build-support": "^2.8.0",
	"copy-webpack-plugin": "4.6.0",
	"webpack": "4.29.6",
	"webpack-cli": "3.3.0",
	"webpack-dev-server": "3.2.1",
	"babel-cli": "6.26.0",
	"babel-preset-env": "1.7.0",
	"babel-preset-react": "6.24.1",
	"babel-loader": "7.1.5"
},
"dependencies": {
	"react": "16.8.6",
	"react-dom": "16.8.6",
	"react-live": "^2.2.2"
},
"scripts": {
	"build": "babel --source-maps -d build src && npm run copy-assets && liferay-npm-bundler",
	"copy-assets": "lnbs-copy-assets",
	"translate": "lnbs-translate",
	"deploy": "npm run build && lnbs-deploy",
	"start": "lnbs-start"
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions