Skip to content

Commit

Permalink
Revert "📦 Update core devDependencies (minor) (#33200)" (#33398)
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Mar 19, 2021
1 parent 4ff9ae8 commit e0ef9c5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 40 deletions.
31 changes: 19 additions & 12 deletions build-system/tasks/dep-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const {cyan, green, red, yellow} = require('kleur/colors');
const {getEsbuildBabelPlugin} = require('../common/esbuild-babel');
const {log, logLocalDev} = require('../common/logging');

const depCheckDir = '.amp-dep-check';

/**
* @typedef {{
* name: string,
Expand Down Expand Up @@ -179,30 +181,35 @@ async function getEntryPointModule() {
.filter((x) => fs.statSync(x).isDirectory())
.map(getEntryPoint);
const allEntryPoints = flatten(extensionEntryPoints).concat(coreBinaries);
await fs.ensureDir(depCheckDir);
const entryPointModule = path.join(depCheckDir, 'entry-point-module.js');
const entryPointData = allEntryPoints
.map((file) => `import './${file}';`)
.map((file) => `import '../${file}';`)
.join('\n');
return entryPointData;
await fs.promises.writeFile(entryPointModule, entryPointData);
logLocalDev('Added all entry points to', cyan(entryPointModule));
return entryPointModule;
}

/**
* @param {string} entryPointModule
* @return {!Promise<ModuleDef>}
*/
async function getModuleGraph(entryPointModule) {
const plugin = getEsbuildBabelPlugin('dep-check', /* enableCache */ true);
const result = await esbuild.build({
stdin: {
contents: entryPointModule,
resolveDir: '.',
},
const bundleFile = path.join(depCheckDir, 'entry-point-bundle.js');
const moduleGraphFile = path.join(depCheckDir, 'module-graph.json');
const plugin = getEsbuildBabelPlugin('dep-check', /* enableCache */ false);
await esbuild.build({
entryPoints: [entryPointModule],
bundle: true,
write: false,
metafile: true,
outfile: bundleFile,
metafile: moduleGraphFile,
plugins: [plugin],
});
logLocalDev('Bundled all entry points into', cyan(bundleFile));

const entryPoints = result.metafile.inputs;
const moduleGraphJson = await fs.readJson(moduleGraphFile);
const entryPoints = moduleGraphJson.inputs;
const moduleGraph = Object.create(null);
moduleGraph.name = entryPointModule;
moduleGraph.deps = [];
Expand All @@ -213,7 +220,7 @@ async function getModuleGraph(entryPointModule) {
deps: entryPoints[entryPoint].imports.map((dep) => dep.path),
});
}
logLocalDev('Extracted module graph');
logLocalDev('Extracted module graph from', cyan(moduleGraphFile));
return moduleGraph;
}

Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ async function compileUnminifiedJs(srcDir, srcFilename, destDir, options) {
const sentinel = '<%= contents %>';
const start = wrapper.indexOf(sentinel);
return {
banner: {js: wrapper.slice(0, start)},
footer: {js: wrapper.slice(start + sentinel.length)},
banner: wrapper.slice(0, start),
footer: wrapper.slice(start + sentinel.length),
};
}

Expand Down
56 changes: 34 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"del": "6.0.0",
"enzyme": "3.11.0",
"enzyme-adapter-preact-pure": "3.0.0",
"esbuild": "0.9.3",
"esbuild": "0.8.57",
"escodegen": "2.0.0",
"eslint": "7.22.0",
"eslint-config-prettier": "8.1.0",
Expand Down Expand Up @@ -118,18 +118,18 @@
"html-minifier": "4.0.0",
"istanbul-middleware": "0.2.2",
"jest-dot-reporter": "1.0.12",
"jest-silent-reporter": "0.5.0",
"jest-silent-reporter": "0.4.0",
"jison": "0.4.18",
"jscodeshift": "0.11.0",
"jsdom": "16.5.0",
"json-stable-stringify": "1.0.1",
"json5": "2.2.0",
"jsonminify": "0.4.1",
"karma": "6.2.0",
"karma": "6.1.1",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-esbuild": "2.1.1",
"karma-esbuild": "2.0.0",
"karma-firefox-launcher": "2.1.0",
"karma-fixture": "0.2.6",
"karma-html2js-preprocessor": "1.1.0",
Expand Down

0 comments on commit e0ef9c5

Please sign in to comment.