From 916b3d357a230fe87f1d6eb2552f070245c5b535 Mon Sep 17 00:00:00 2001 From: Jan Bobisud Date: Thu, 22 Nov 2018 11:41:51 +0100 Subject: [PATCH] Update schema version to support strict whitelist --- README.md | 13 ++++++++----- lib/broccoli/fastboot-config.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4fa4d133d..4b7c88817 100644 --- a/README.md +++ b/README.md @@ -81,17 +81,17 @@ To allow your app to require a package, add it to the // ... }, "dependencies": { - // ... + "lodash": "..." }, "fastbootDependencies": [ - "rsvp", + "lodash", "path" ] } ``` The `fastbootDependencies` in the above example means the only node -modules your Ember app can use are `rsvp` and `path`. +modules your Ember app can use are `lodash` and `path`. If the package you are using is not built-in to Node, **you must also specify the package and a version in the `package.json` `dependencies` @@ -101,15 +101,18 @@ hash.** Built-in modules (`path`, `fs`, etc.) only need to be added to ### Using Dependencies From your Ember.js app, you can run `FastBoot.require()` to require a -package. This is identical to the CommonJS `require` except it checks +package or its submodule. This is identical to the CommonJS `require` except it checks all requests against the whitelist first. ```js let path = FastBoot.require('path'); let filePath = path.join('tmp', session.getID()); + +let _ = FastBoot.require('lodash'); +let at = FastBoot.require('lodash/at'); ``` -If you attempt to require a package that is not in the whitelist, +If you attempt to require a package or submodule from package that is not in the whitelist, FastBoot will raise an exception. Note that the `FastBoot` global is **only** available when running in diff --git a/lib/broccoli/fastboot-config.js b/lib/broccoli/fastboot-config.js index 0f7e5b659..0d993b397 100644 --- a/lib/broccoli/fastboot-config.js +++ b/lib/broccoli/fastboot-config.js @@ -11,7 +11,7 @@ const Plugin = require('broccoli-plugin'); const stringify = require('json-stable-stringify'); -const LATEST_SCHEMA_VERSION = 3; +const LATEST_SCHEMA_VERSION = 4; module.exports = class FastBootConfig extends Plugin { constructor(inputNode, options) {