Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10053 from ember-cli/hjblue/node-esm
- Loading branch information
Showing
19 changed files
with
325 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
'use strict'; | ||
const findUp = require('find-up'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
|
||
module.exports = function (file, dir) { | ||
let buildFilePath = findUp.sync(file, { cwd: dir }); | ||
module.exports = async function (dir) { | ||
let buildFilePath = null; | ||
|
||
// Note: In the future this should throw | ||
if (!buildFilePath) { | ||
for (let ext of ['js', 'mjs', 'cjs']) { | ||
let candidate = findUp.sync(`ember-cli-build.${ext}`, { cwd: dir }); | ||
if (candidate) { | ||
buildFilePath = candidate; | ||
break; | ||
} | ||
} | ||
|
||
if (buildFilePath === null) { | ||
return null; | ||
} | ||
|
||
process.chdir(path.dirname(buildFilePath)); | ||
|
||
let buildFile = null; | ||
let buildFileUrl = url.pathToFileURL(buildFilePath); | ||
try { | ||
buildFile = require(buildFilePath); | ||
// eslint-disable-next-line node/no-unsupported-features/es-syntax | ||
let fn = (await import(buildFileUrl)).default; | ||
return fn; | ||
} catch (err) { | ||
err.message = `Could not require '${file}': ${err.message}`; | ||
err.message = `Could not \`import('${buildFileUrl}')\`: ${err.message}`; | ||
throw err; | ||
} | ||
|
||
return buildFile; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Introduction | ||
|
||
This is the introduction markdown file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Outro | ||
|
||
This is the outro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Introduction | ||
|
||
This is the introduction markdown file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Outro | ||
|
||
This is the outro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hello world | ||
|
||
This is a test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const mergeTrees = require('broccoli-merge-trees'); | ||
const concat = require('broccoli-concat'); | ||
const funnel = require('broccoli-funnel'); | ||
|
||
module.exports = function() { | ||
const txt = funnel('app', { | ||
include: ['*.txt'], | ||
}); | ||
const md = funnel('app', { | ||
include: ['*.md'], | ||
}); | ||
const concated = concat(txt, { | ||
outputFile: 'text.txt', | ||
}); | ||
|
||
return mergeTrees([concated, md], {annotation: 'The final merge'}); | ||
} |
Oops, something went wrong.