New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore option throwing errors #265

Closed
larsgw opened this Issue Apr 29, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@larsgw
Contributor

larsgw commented Apr 29, 2018

Using the ignore option results in the following error:

TypeError: Cannot read property 'code' of null while parsing file: /home/larsw/project/node_modules/expect.js/index.js
    at babel.transform (/home/larsw/project/node_modules/babelify/index.js:31:25)
    at /home/larsw/project/node_modules/@babel/core/lib/transform.js:29:32
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Using the following babelify options:

{
  global: true,
  ignore: ['node_modules/expect.js/']
}

Source (AFAICT)

Caused by this, due to result being null:

var code = result.code;

This happens on ignored files, as expected. My guess is that that happens because of

    if (
      ignoreFile &&
      shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)
    ) {
      return null;
    }

in @babel/core.

This causes

  • loadPrivatePartialConfig to return null
    const configChain = buildRootChain(args, context);
    if (!configChain) return null;
    (source), which causes
  • loadFullConfig to return null
    const result = loadPrivatePartialConfig(inputOpts);
    if (!result) {
      return null;
    }
    (source), which causes
  • loadConfig to return null
    const config = loadFullConfig(opts);
    
    return config ? config.options : null;
    (source), which causes
  • transform to return null
    cfg = loadConfig(opts);
    if (cfg === null) return cb(null, null);
    (source)

Program Version
Babel v7.0.0-beta.44
Babelify v8.0.0 (plus the #255 PR)
Browserify v16.2.0
Node.js v8.11.2

Full options:

browserify()
  .exclude(['citation-js'])
  .add('./test/wrapper.js')
  .transform(babelify, {
    global: true,
    ignore: ['node_modules/expect.js/']
  })
  .bundle()
  .pipe(fs.createWriteStream(path.join(__dirname, '../build/test.citation.js')))

larsgw added a commit to larsgw/babelify that referenced this issue Apr 29, 2018

Check if result isn't null
This may be the case if files are ignored. I do
not know what the other cases are, and if they
should be handled differently, but at least they
don't cause error like this.

See babel#265

larsgw added a commit to larsgw/babelify that referenced this issue Apr 29, 2018

Check if result is null
This may be the case if files are ignored. I do
not know what the other cases are, and if they
should be handled differently, but at least they
don't cause error like this.

See babel#265

larsgw added a commit to larsgw/citation.js that referenced this issue Apr 30, 2018

[site:test] Fix browser tests again
expect.js doesn't play nicely with Babel, so it
shouldn't be transformed by Babelify.^1 Note that
the ignore option in Babelify is buggy ^2, so
this might not work on your end.

^1 Automattic/expect.js#149
^2 babel/babelify#265

larsgw added a commit to larsgw/citation.js that referenced this issue May 2, 2018

[test:input] Set up HTTP request mocking (#136)
* [site:test] Fix browser tests again

expect.js doesn't play nicely with Babel, so it
shouldn't be transformed by Babelify.^1 Note that
the ignore option in Babelify is buggy ^2, so
this might not work on your end.

^1 Automattic/expect.js#149
^2 babel/babelify#265

* [test:input] Set up HTTP request mocking

Set up proper HTTP request mocking by mocking
exports with mock-require. Not possible in the
browser, but it wasn't before, so this counts
as an improvement.

Previously done by nock, but this didn't work for
requests made through sync-request, as that
spawns a child process over which nock has no
control.

See #68
See 509d911
Close #134

* [test:input] Increase coverage of input plugins

See #123 

* [package] Add non-npm patch to dependencies

See babel/babelify#267

loganfsmyth added a commit that referenced this issue Sep 3, 2018

Check if result is null (#267)
This may be the case if files are ignored. I do
not know what the other cases are, and if they
should be handled differently, but at least they
don't cause error like this.

See #265
@loganfsmyth

This comment has been minimized.

Member

loganfsmyth commented Sep 4, 2018

Fixed in #267

@loganfsmyth loganfsmyth closed this Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment