Skip to content

Commit

Permalink
remove esm from the build
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Jul 3, 2024
1 parent 0d6d8f3 commit a41538a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 38 deletions.
15 changes: 8 additions & 7 deletions gulp/closure-task.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { esmRequire, gCCLanguageNames, observableFromStreams, shouldRunInChildProcess, spawnGulpCommandInChildProcess, targetDir } from "./util.js";
import { gCCLanguageNames, observableFromStreams, shouldRunInChildProcess, spawnGulpCommandInChildProcess, targetDir } from './util.js';

import gulp from 'gulp';
import sourcemaps from 'gulp-sourcemaps';
Expand Down Expand Up @@ -77,14 +77,15 @@ export const closureTask = ((cache) => memoizeTask(cache, async function closure
const entry_point = Path.join(src, `${entry}.cls.js`);
const externsPath = Path.join(out, `${entry}.externs.js`);

const exportedImports = [
const exportedImports = [];
for (const publicModulePath of [
Path.join(srcAbsolute, `${entry}.js`)
].reduce((entries, publicModulePath) => [
...entries, {
]) {
exportedImports.push({
publicModulePath,
exports_: getPublicExportedNames(esmRequire(publicModulePath))
}
], []);
exports_: getPublicExportedNames(await import(publicModulePath))
});
}

await Promise.all([
fs.promises.writeFile(externsPath, generateExternsFile(exportedImports)),
Expand Down
21 changes: 0 additions & 21 deletions gulp/esm-require.cjs

This file was deleted.

6 changes: 3 additions & 3 deletions gulp/package-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ const createScopedPackageJSON = (target, format) => (({ name, ...orig }) =>
// set "main" to "Ix" if building scoped UMD target, otherwise "node"
main: format === 'umd' ? `dom.js` : `node.js`,
// set "type" to `module` or `commonjs` (https://nodejs.org/api/packages.html#packages_type)
type: format === 'esm' ? `module` : `commonjs`,
type: format === 'esm' || format === 'cls' ? `module` : `commonjs`,
// set "module" if building scoped ESM target
module: format === 'esm' ? `node.js` : undefined,
module: format === 'esm' || format === 'cls' ? `node.js` : undefined,
// set "sideEffects" to false as a hint to Webpack that it's safe to tree-shake the ESM target
sideEffects: format === 'esm' ? false : undefined,
sideEffects: format === 'esm' || format === 'cls' ? false : undefined,
// include "esm" settings for https://www.npmjs.com/package/esm if building scoped ESM target
esm: format === `esm` ? { mode: `auto`, sourceMap: true } : undefined,
// set "types" to "dom" if building scoped UMD target, otherwise "node"
Expand Down
3 changes: 1 addition & 2 deletions gulp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ReplaySubject, empty as ObservableEmpty, throwError as ObservableThrow,
import { share, flatMap, takeUntil, defaultIfEmpty, merge } from 'rxjs/operators/index.js';
const asyncDone = util.promisify(asyncDoneSync);
import { createRequire } from 'node:module';
import esmRequire from './esm-require.cjs'

const require = createRequire(import.meta.url);

Expand Down Expand Up @@ -155,7 +154,7 @@ export {
knownTargets, knownModules, tasksToSkipPerTargetOrFormat, gCCLanguageNames,

taskName, packageName, tsconfigName, targetDir, combinations, observableFromStreams,
esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess,
shouldRunInChildProcess, spawnGulpCommandInChildProcess,
};

export const targetAndModuleCombinations = [...combinations(targets, modules)];
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"eslint": "8.52.0",
"eslint-plugin-jest": "27.4.2",
"eslint-plugin-unicorn": "49.0.0",
"esm": "https://github.com/jsg2021/esm/releases/download/v3.x.x-pr883/esm-3.x.x-pr883.tgz",
"glob": "10.3.10",
"google-closure-compiler": "20240317.0.0",
"gulp": "4.0.2",
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5456,10 +5456,6 @@ [email protected]:
strip-ansi "^6.0.1"
text-table "^0.2.0"

"esm@https://github.com/jsg2021/esm/releases/download/v3.x.x-pr883/esm-3.x.x-pr883.tgz":
version "3.2.25"
resolved "https://github.com/jsg2021/esm/releases/download/v3.x.x-pr883/esm-3.x.x-pr883.tgz#c463cfa4e14aceea6b7cd7e669ef90de072ea60a"

esniff@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz#a4d4b43a5c71c7ec51c51098c1d8a29081f9b308"
Expand Down

0 comments on commit a41538a

Please sign in to comment.