-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
TBH I can't find the exact code for esx-optimize@1.1.1 published to npm as there are no tags in this repo and it doesn't look like it's in the history, but whatever is published to npm does not optimise any files because it expects a file to be both .js and .mjs which obviously isn't possible:
function unsupported (filename) {
const ext = extname(filename)
return ext !== '.js' || ext !== '.mjs'
}I expect it should be:
function unsupported (filename) {
const ext = extname(filename)
return ext !== '.js' && ext !== '.mjs'
}With this in mind, what is the status of esx, are you using it in production via some other means (babel plugin)? Also, is there any plan to support the legacy context API by any chance?
Really interesting project BTW!
Full npm module here:
'use strict'
const convert = require('to-esx')
const Module = require('module')
const { extname } = require('path')
const { _compile } = Module.prototype
require('esx') //load esx into the cache
const esx = require.resolve('esx')
const preloaded = require.main === undefined
function unsupported (filename) {
const ext = extname(filename)
return ext !== '.js' || ext !== '.mjs'
}
function install (opts = {}) {
const { exclude = () => false } = opts
Module.prototype._compile = function (content, filename) {
if (filename === esx || exclude(filename) || unsupported(filename)) {
return _compile.call(this, content, filename)
}
try {
const converted = convert(content)
return _compile.call(this, converted, filename)
} catch (e) {
console.log(e, filename, content)
}
return content
}
return module.exports
}
function restore () {
Module.prototype._compile = _compile
return module.exports
}
if (preloaded) install()
module.exports = { install, restore }Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels