mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Allow client modules to be imported by server modules.
This commit is contained in:
@@ -121,7 +121,8 @@ export default class ImportScanner {
|
||||
}
|
||||
|
||||
getOutputFiles(options) {
|
||||
return this.outputFiles;
|
||||
// Return all installable output files.
|
||||
return this.outputFiles.filter(file => !! file.installPath);
|
||||
}
|
||||
|
||||
_findImportedModuleIdentifiers(file) {
|
||||
|
||||
@@ -1316,6 +1316,16 @@ _.extend(PackageSource.prototype, {
|
||||
const fileOptions = {};
|
||||
const dirs = files.pathDirname(relPath).split(files.pathSep);
|
||||
|
||||
// If the file is restricted to the opposite architecture, make sure
|
||||
// it is not evaluated eagerly.
|
||||
if (arch === "os") {
|
||||
if (dirs.indexOf("client") >= 0) {
|
||||
fileOptions.lazy = true;
|
||||
}
|
||||
} else if (dirs.indexOf("server") >= 0) {
|
||||
fileOptions.lazy = true;
|
||||
}
|
||||
|
||||
if (dirs.indexOf("node_modules") >= 0) {
|
||||
fileOptions.lazy = true;
|
||||
fileOptions.transpile = false;
|
||||
@@ -1373,7 +1383,6 @@ _.extend(PackageSource.prototype, {
|
||||
const anyLevelExcludes = [
|
||||
/^tests\/$/,
|
||||
/^node_modules\/$/,
|
||||
arch === "os" ? /^client\/$/ : /^server\/$/,
|
||||
...sourceReadOptions.exclude
|
||||
];
|
||||
|
||||
|
||||
1
tools/tests/apps/modules/client/eager.js
Normal file
1
tools/tests/apps/modules/client/eager.js
Normal file
@@ -0,0 +1 @@
|
||||
export const name = module.id;
|
||||
@@ -5,6 +5,12 @@ import {Meteor as ImportedMeteor} from "meteor/meteor";
|
||||
describe("app modules", () => {
|
||||
it("can be imported using absolute identifiers", () => {
|
||||
assert.strictEqual(require("/tests"), exports);
|
||||
assert.strictEqual(
|
||||
// Client modules should be importable by server modules, though not
|
||||
// vice-versa.
|
||||
require("/client/eager").name,
|
||||
"/client/eager.js"
|
||||
);
|
||||
});
|
||||
|
||||
it("can have different file extensions", () => {
|
||||
|
||||
Reference in New Issue
Block a user