mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
This reworks a few things in building and distributing React. The biggest change is using fbjs to share dependencies with other libraries. We're also using Gulp for some build steps.
49 lines
1.4 KiB
JavaScript
Executable File
49 lines
1.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// -*- mode: js -*-
|
|
// vim: set ft=javascript :
|
|
|
|
'use strict';
|
|
|
|
var babel = require('babel');
|
|
|
|
var devExpressionPlugin = require('fbjs/scripts/babel/dev-expression');
|
|
|
|
var TRANSFORM_IGNORE_RE = /^WebComponents$/;
|
|
|
|
require('commoner').version(
|
|
require('../package.json').version
|
|
).resolve(function(id) {
|
|
var context = this;
|
|
|
|
// Note that the result of context.getProvidedP() is cached for the
|
|
// duration of the build, so it is both consistent and cheap to
|
|
// evaluate multiple times.
|
|
return context.getProvidedP().then(function(idToPath) {
|
|
// If a module declares its own identifier using @providesModule
|
|
// then that identifier will be a key in the idToPath object.
|
|
if (idToPath.hasOwnProperty(id)) {
|
|
return context.readFileP(idToPath[id]);
|
|
}
|
|
|
|
// Otherwise assume the identifier maps directly to a path in the
|
|
// filesystem.
|
|
return context.readModuleP(id);
|
|
});
|
|
|
|
}).process(function(id, source) {
|
|
var context = this;
|
|
|
|
// This is hacky but that's ok… It really only matters for tests since it
|
|
// won't otherwise be in the dependency tree.
|
|
if (!TRANSFORM_IGNORE_RE.test(id)) {
|
|
// This is where JSX, ES6, etc. desugaring happens.
|
|
source = babel.transform(source, {
|
|
blacklist: ['spec.functionName', 'validation.react'],
|
|
plugins: [devExpressionPlugin],
|
|
filename: id,
|
|
}).code;
|
|
}
|
|
|
|
return source;
|
|
});
|