<commit_before>'use strict'

const path = require('path')

const babel = require('babel-core')
const sourceMapSupport = require('source-map-support')

// Resolve the example location relative to the current working directory.
const mod = path.resolve('example', process.argv[2])

// Fix up argv so the example thinks it was invoked directly. Don't fix other
// properties like execArgv.
process.argv = ['node', mod].concat(process.argv.slice(3))

// Cache source maps for the example modules that were transformed on the fly.
const transformMaps = Object.create(null)

// Hook up source map support to rewrite stack traces. Use cached source maps
// but fall back to retrieving them from the pragma in the source file. The
// latter will work for `npm run build` output.
sourceMapSupport.install({
  environment: 'node',
  handleUncaughtExceptions: false,
  retrieveSourceMap (source) {
    return transformMaps[source] || sourceMapSupport.retrieveSourceMap(source)
  }
})

// Only modules in the example dir are transformed. All other modules are
// assumed to be compatible. This means the examples run with the build code
// as it's distributed on npm.
const exampleDir = path.dirname(mod)
const requirePlain = require.extensions['.js']
require.extensions['.js'] = function (module, filename) {
  if (!filename.startsWith(exampleDir + '/')) {
    requirePlain(module, filename)
    return
  }

  const result = babel.transformFileSync(filename, {
    sourceMap: 'both',
    ast: false<commit_msg>don't include sourcemap in transformed example code<commit_after>'use strict'

const path = require('path')

const babel = require('babel-core')
const sourceMapSupport = require('source-map-support')

// Resolve the example location relative to the current working directory.
const mod = path.resolve('example', process.argv[2])

// Fix up argv so the example thinks it was invoked directly. Don't fix other
// properties like execArgv.
process.argv = ['node', mod].concat(process.argv.slice(3))

// Cache source maps for the example modules that were transformed on the fly.
const transformMaps = Object.create(null)

// Hook up source map support to rewrite stack traces. Use cached source maps
// but fall back to retrieving them from the pragma in the source file. The
// latter will work for `npm run build` output.
sourceMapSupport.install({
  environment: 'node',
  handleUncaughtExceptions: false,
  retrieveSourceMap (source) {
    return transformMaps[source] || sourceMapSupport.retrieveSourceMap(source)
  }
})

// Only modules in the example dir are transformed. All other modules are
// assumed to be compatible. This means the examples run with the build code
// as it's distributed on npm.
const exampleDir = path.dirname(mod)
const requirePlain = require.extensions['.js']
require.extensions['.js'] = function (module, filename) {
  if (!filename.startsWith(exampleDir + '/')) {
    requirePlain(module, filename)
    return
  }

  const result = babel.transformFileSync(filename, {
    sourceMap: true,
    ast: false
{'fraction_non_alphanumeric': 0.1011865524060646, 'fraction_numerical': 0.0013183915622940012, 'mean_word_length': 4.371681415929204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7098537', 'n_tokens_mistral': 827, 'n_tokens_neox': 813, 'n_words': 321}