зеркало из https://github.com/mozilla/normandy.git
Use a single config object for recipe-client dependencies.
This commit is contained in:
Родитель
5ae3f933b5
Коммит
1a7b6d5f92
|
@ -38,20 +38,22 @@ To add a dependency:
|
||||||
bugs from downloading newer versions of libraries that we haven't tested
|
bugs from downloading newer versions of libraries that we haven't tested
|
||||||
the add-on against yet.
|
the add-on against yet.
|
||||||
|
|
||||||
2. Add the dependency to ``recipe-client-addon/webpack.config.js`` using the
|
2. Add the dependency to ``recipe-client-addon/webpack.config.js`` as an entry
|
||||||
``libraryConfig`` function:
|
point:
|
||||||
|
|
||||||
.. code-block:: javascript
|
.. code-block:: javascript
|
||||||
|
|
||||||
module.exports = [
|
module.exports = {
|
||||||
// First argument is the name to export the library under
|
entry: {
|
||||||
// Second argument is a path to the library's folder in node_modules
|
// The key is the name to export the library under
|
||||||
libraryConfig("ajv", "./node_modules/ajv"),
|
// The value is the path to the library's folder in node_modules
|
||||||
];
|
ajv: "./node_modules/ajv",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
3. Re-build the vendor directory via ``npm run build``. Ensure that a
|
3. Re-build the vendor directory via ``npm run build``. Ensure that licensing
|
||||||
``libraryName_LICENSE`` file was generated withing ``vendor`` so that we have
|
info for the library was added to the ``LICENSE_THIRDPARTY`` file generated
|
||||||
licensing information for our dependencies.
|
within ``vendor`` so that we have licensing information for our dependencies.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -3,52 +3,38 @@ var path = require("path");
|
||||||
var ConcatSource = require("webpack-sources").ConcatSource;
|
var ConcatSource = require("webpack-sources").ConcatSource;
|
||||||
var LicenseWebpackPlugin = require("license-webpack-plugin");
|
var LicenseWebpackPlugin = require("license-webpack-plugin");
|
||||||
|
|
||||||
/**
|
module.exports = {
|
||||||
* Create a webpack config object for a library. The compiled library will be
|
context: __dirname,
|
||||||
* output to the vendor directory.
|
entry: {
|
||||||
*
|
mozjexl: "./node_modules/mozjexl/",
|
||||||
* @param {String} name
|
},
|
||||||
* Library name. This generally should match the name used on npm.
|
output: {
|
||||||
* @param {String} entryPoint
|
path: path.resolve(__dirname, "vendor/"),
|
||||||
* Path to the entry point of the library. Webpack can handle directories with
|
filename: "[name].js",
|
||||||
* a package.json file, so normally this is "./node_modules/libname".
|
library: "[name]",
|
||||||
*/
|
libraryTarget: "this",
|
||||||
function libraryConfig(name, entryPoint) {
|
},
|
||||||
return {
|
plugins: [
|
||||||
context: __dirname,
|
/**
|
||||||
entry: {
|
* Plugin that appends "this.EXPORTED_SYMBOLS = ["libname"]" to assets
|
||||||
[name]: entryPoint,
|
* output by webpack. This allows built assets to be imported using
|
||||||
},
|
* Cu.import.
|
||||||
output: {
|
*/
|
||||||
path: path.resolve(__dirname, "vendor/"),
|
function ExportedSymbols() {
|
||||||
filename: "[name].js",
|
this.plugin("emit", function(compilation, callback) {
|
||||||
library: name,
|
for (const libraryName in compilation.entrypoints) {
|
||||||
libraryTarget: "this",
|
const assetName = `${libraryName}.js`; // Matches output.filename
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
/**
|
|
||||||
* Plugin that appends "this.EXPORTED_SYMBOLS = ["libname"]" to assets
|
|
||||||
* output by webpack. This allows built assets to be imported using
|
|
||||||
* Cu.import.
|
|
||||||
*/
|
|
||||||
function ExportedSymbols() {
|
|
||||||
this.plugin("emit", function(compilation, callback) {
|
|
||||||
const assetName = `${name}.js`;
|
|
||||||
compilation.assets[assetName] = new ConcatSource(
|
compilation.assets[assetName] = new ConcatSource(
|
||||||
compilation.assets[assetName],
|
compilation.assets[assetName],
|
||||||
`this.EXPORTED_SYMBOLS = ["${name}"];`
|
`this.EXPORTED_SYMBOLS = ["${libraryName}"];` // Matches output.library
|
||||||
);
|
);
|
||||||
callback();
|
}
|
||||||
});
|
callback();
|
||||||
},
|
});
|
||||||
new LicenseWebpackPlugin({
|
},
|
||||||
pattern: /^(MIT|ISC|MPL.*|Apache.*|BSD.*)$/,
|
new LicenseWebpackPlugin({
|
||||||
filename: `${name}_LICENSE`,
|
pattern: /^(MIT|ISC|MPL.*|Apache.*|BSD.*)$/,
|
||||||
}),
|
filename: `LICENSE_THIRDPARTY`,
|
||||||
],
|
}),
|
||||||
};
|
],
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
libraryConfig("mozjexl", "./node_modules/mozjexl"),
|
|
||||||
];
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче