title: Babel 7 not transforming builtin subclasses properly
body: <p>Babel version: 7.6.0</p>
  
  <p>I am working on <a href="https://github.com/SylvainBigonneau/edtf-datepicker" rel="nofollow noreferrer">a JavaScript widget</a> meant for browser use, but it depends on a library built for NodeJS ( <a href="https://github.com/inukshuk/edtf.js/" rel="nofollow noreferrer">edtf.js</a> ). Particularly, it extends the <code>Date</code> builtin in <a href="https://github.com/inukshuk/edtf.js/blob/master/src/date.js" rel="nofollow noreferrer">this file</a>.</p>
  
  <p>So far, it seems to work on all modern browsers I have tested it with. But to make sure it is bulletproof to older ones, I thought of Babelifying the edtf library. Here is the browserify configuration from <a href="https://github.com/SylvainBigonneau/edtf-datepicker/blob/babelify/Gruntfile.js" rel="nofollow noreferrer">my Gruntfile.js</a>:</p>
  
  <pre class="lang-js prettyprint-override"><code>browserify: {
    development: {
      src: [
        "node_modules/edtf/index.js"
      ],
      dest: './dist/js/edtf.js',
      options: {
        browserifyOptions: { standalone: 'edtf' },
        transform: [["babelify", {
          "presets": ["@babel/preset-env"], "plugins": [["@babel/transform-runtime", {"helpers": false}]]
        }]]
      }
    }
  },
  </code></pre>
  
  <p>After a lot of tinkering, this configuration at least does not trigger any error when the resulting javascript file is loaded on the page, but as soon as I start using the library it breaks with this error:</p>
  
  <pre><code>edtf.js:3040 Uncaught TypeError: this is not a Date object.
     at Date.getUTCFullYear (&lt;anonymous&gt;)
     at Date.get (edtf.js:3040)
     at Date.toEDTF (edtf.js:2960)
     at Date.value (edtf.js:5696)
     at new Date (&lt;anonymous&gt;)
  </code></pre>
  
  <p>A <a href="https://stackoverflow.com/a/37609218/1439597">previous SO answer</a> correctly points out that <strong>builtin subclasses are only partially supported by Babel</strong>, <a href="https://babeljs.io/docs/learn-es2015/#subclassable-built-ins" rel="nofollow noreferrer">according to their documentation</a>, and suggests using the <a href="https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend" rel="nofollow noreferrer">transform-builtin-extend</a> plugin, which is sadly unmaintained for 2 years and only suits Babel 6.</p>
  
  <p>Shouldn't the <a href="https://babeljs.io/docs/en/babel-plugin-transform-classes" rel="nofollow noreferrer">transform classes</a> work for that? I tried including it in my config, but it changed strictly nothing.</p>
  
  <p>Anyway, if anyone has any advice on how to move forward, <a href="https://github.com/SylvainBigonneau/edtf-datepicker/tree/babelify" rel="nofollow noreferrer">here is the github branch to try it for yourself</a>, simply run <code>npm install</code>, <code>npm run build</code> and open the <code>index.html</code> file in your browser. Any recommendation is welcomed: I am not married to the Babel idea, but I want to make sure that I can safely use this edtf library and have it working on the majority of browsers.</p>