diff --git a/scripts/build.js b/scripts/build.js index bb24629d..63aaa57b 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -44,18 +44,17 @@ async function main() { require.resolve("source-map-support/register") ); + // detect unexpected asset emissions from core build if ( Object.keys(cliAssets).length || - Object.keys(indexAssets).length || + Object.keys(indexAssets).some(asset => !asset.startsWith('locales/')) || Object.keys(nodeLoaderAssets).length || Object.keys(relocateLoaderAssets).length || Object.keys(shebangLoaderAssets).length || - Object.keys(tsLoaderAssets).length || + Object.keys(tsLoaderAssets).some(asset => !asset.startsWith('lib/')) || Object.keys(sourcemapAssets).length ) { - console.error( - "Assets emitted by core build, these need to be written into the dist directory" - ); + console.error("New assets are being emitted by the core build"); } writeFileSync(__dirname + "/../dist/ncc/cli.js", cli); diff --git a/src/loaders/relocate-loader.js b/src/loaders/relocate-loader.js index c8d3340c..556e346f 100644 --- a/src/loaders/relocate-loader.js +++ b/src/loaders/relocate-loader.js @@ -267,8 +267,8 @@ module.exports = function (code) { glob(assetDirPath + '/**/*', { mark: true, ignore: 'node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files)) ); await Promise.all(files.map(async file => { - // dont emit empty directories - if (file.endsWith('/')) + // dont emit empty directories or ".js" files + if (file.endsWith('/') || file.endsWith('.js')) return; const source = await new Promise((resolve, reject) => fs.readFile(file, (err, source) => err ? reject(err) : resolve(source)) diff --git a/test/index.test.js b/test/index.test.js index 650ce90d..a8a29fa1 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -56,6 +56,10 @@ function clearDir (dir) { for (const integrationTest of fs.readdirSync(__dirname + "/integration")) { // ignore e.g.: `.json` files if (!/\.(mjs|tsx?|js)$/.test(integrationTest)) continue; + + // disabled pending https://github.com/zeit/ncc/issues/141 + if (integrationTest.endsWith('loopback.js')) continue; + it(`should evaluate ${integrationTest} without errors`, async () => { const { code, map, assets } = await ncc( __dirname + "/integration/" + integrationTest,