Invalid property of 'default'
See original GitHub issueThis is index.js of babel-plugin-dynamic-import-node which I downloaded from npm, also v.1.0.2
Object.defineProperty(exports, "__esModule", {
value: true
});
var _babelTemplate = require('babel-template');
var _babelTemplate2 = _interopRequireDefault(_babelTemplate);
var _babelPluginSyntaxDynamicImport = require('babel-plugin-syntax-dynamic-import');
var _babelPluginSyntaxDynamicImport2 = _interopRequireDefault(_babelPluginSyntaxDynamicImport);
var _babelTypes = require('babel-types');
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var TYPE_IMPORT = 'Import';
var buildImport = (0, _babelTemplate2['default'])('\n Promise.resolve().then(() => require(SOURCE))\n');
exports['default'] = function () {
return {
inherits: _babelPluginSyntaxDynamicImport2['default'],
visitor: {
CallExpression: function () {
function CallExpression(path) {
if (path.node.callee.type === TYPE_IMPORT) {
var importArgument = path.node.arguments[0];
var newImport = buildImport({
SOURCE: t.isStringLiteral(importArgument) || t.isTemplateLiteral(importArgument) ? path.node.arguments : t.templateLiteral([t.templateElement({ raw: '', cooked: '' }), t.templateElement({ raw: '', cooked: '' }, true)], path.node.arguments)
});
path.replaceWith(newImport);
}
}
return CallExpression;
}()
}
};
};
Why is it completely different than index.js here, in this repo?
Btw. the one on GitHub doesn’t seem to work (still returns unexpected token), the one on npm works, but only after you add module.exports = exports["default"]
at the end of index.js, otherwise babel-jest
returns Plugin 1 specified in "base" provided an invalid property of "default"
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
bundling failed: Error: Plugin 0 provided an invalid property of ...
This is bug in babel-preset-react-native. Set the version: yarn remove babel-preset-react-native yarn add babel-preset-react-native@2.1.0.
Read more >error: 'Plugin 0 provided an invalid property of "default"' when ...
error: 'Plugin 0 provided an invalid property of "default"' when using with React Native + TypeScript #3897.
Read more >Invalid Property Value Error - OutSystems 10 Documentation
The Invalid Property Value error is issued in the following ... Edit the Default Value property of the element and set a literal...
Read more >Coding error detected, it must be fixed by a programmer
Coding error detected, it must be fixed by a programmer: Invalid property requested, or the property does not has a default value.
Read more >Why do I get the error "Invalid default value for property" when ...
Invalid default value for property 'B' in class 'Example':. The property 'A' in class 'Example' must be accessed from a class instance because ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 - We ran into the
default
issue as well when trying to use dynamic imports + Jest + Meteor, but the following works:EDIT: As of the latest version of this package, this workaround seems to be unnecessary.
It’s certainly something this package should have fixed initially, but “not a root .babelrc” isn’t a common use case, so we didn’t anticipate it.