question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid property of 'default'

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
menewmancommented, Jul 28, 2018

+1 - We ran into the default issue as well when trying to use dynamic imports + Jest + Meteor, but the following works:

module.exports = require('babel-jest').createTransformer({
  presets: ['flow', 'latest', 'react', 'stage-3'],
  plugins: [
    'babel-plugin-transform-runtime',
    'babel-plugin-transform-object-rest-spread',
    'syntax-dynamic-import',
    require('babel-plugin-dynamic-import-node').default // https://github.com/airbnb/babel-plugin-dynamic-import-node/issues/27
  ]
});

EDIT: As of the latest version of this package, this workaround seems to be unnecessary.

0reactions
ljharbcommented, Aug 22, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found