Skip to content

Commit e461dd8

Browse files
authored
Merge pull request #227 from xg-wang/require
Restore allowing fallback require from working directory
2 parents a0b5ea2 + 31e0aab commit e461dd8

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ build command:
6363
$ ember build --environment production
6464
```
6565

66-
(You will need to have already set up the Ember CLI FastBoot addon. For
67-
more information, see the [FastBoot quickstart][quickstart].)
66+
(You will need to have already set up the [ember-cli-fastboot](https://github.com/ember-fastboot/ember-cli-fastboot) addon.
67+
For more information, see the [FastBoot quickstart][quickstart].)
6868

6969
[quickstart]: https://www.ember-fastboot.com/quickstart
7070

7171
Once this is done, you will have a `dist` directory that contains the
72-
multi-environment build of your app. Upload this file to your FastBoot
73-
server.
72+
multi-environment build of your app.
73+
74+
Run the command to install run time node modules:
75+
76+
```sh
77+
$ cd dist/
78+
$ npm install
79+
```
80+
81+
Upload the `dist/` folder including `node_modules` to your FastBoot server.
7482

7583
### Command Line
7684

src/ember-app.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,16 @@ class EmberApp {
136136
let isWhitelisted = whitelist.indexOf(packageName) > -1;
137137

138138
if (isWhitelisted) {
139-
let resolvedModulePath = resolve.sync(moduleName, { basedir: distPath });
140-
return require(resolvedModulePath);
139+
try {
140+
let resolvedModulePath = resolve.sync(moduleName, { basedir: distPath });
141+
return require(resolvedModulePath);
142+
} catch (error) {
143+
if (error.code === 'MODULE_NOT_FOUND') {
144+
return require(moduleName);
145+
} else {
146+
throw error;
147+
}
148+
}
141149
}
142150

143151
if (isLegacyWhitelist) {
@@ -147,7 +155,6 @@ class EmberApp {
147155
if (fs.existsSync(nodeModulesPath)) {
148156
return require(nodeModulesPath);
149157
} else {
150-
// If it's not on disk, assume it's a built-in node package
151158
return require(moduleName);
152159
}
153160
} else {
@@ -390,7 +397,6 @@ class EmberApp {
390397
// set schema version to 1 if not defined
391398
schemaVersion = schemaVersion || FastBootSchemaVersions.base;
392399
debug('Current schemaVersion from `ember-cli-fastboot` is %s while latest schema version is %s', schemaVersion, currentSchemaVersion);
393-
394400
if (schemaVersion > currentSchemaVersion) {
395401
let errorMsg = chalk.bold.red('An incompatible version between `ember-cli-fastboot` and `fastboot` was found. Please update the version of fastboot library that is compatible with ember-cli-fastboot.');
396402
throw new Error(errorMsg);

0 commit comments

Comments
 (0)