Skip to content

Commit

Permalink
first requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Nov 9, 2021
1 parent cd8df5b commit d295901
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 109 deletions.
3 changes: 1 addition & 2 deletions integrationTests/ts-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"typescript-4.2": "npm:[email protected]",
"typescript-4.3": "npm:[email protected]",
"typescript-4.4": "npm:[email protected]",
"typescript-4.5": "npm:[email protected]",
"typescript-next": "npm:typescript@next"
"typescript-4.5": "npm:[email protected]"
}
}
3 changes: 1 addition & 2 deletions integrationTests/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"typescript-4.2": "npm:[email protected]",
"typescript-4.3": "npm:[email protected]",
"typescript-4.4": "npm:[email protected]",
"typescript-4.5": "npm:[email protected]",
"typescript-next": "npm:typescript@next"
"typescript-4.5": "npm:[email protected]"
}
}
4 changes: 1 addition & 3 deletions integrationTests/webpack/webpack.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"mode": "production",
"entry": "./entry.js",
"output": {
"library": {
"type": "commonjs2"
}
"libraryTarget": "commonjs2"
}
}
83 changes: 0 additions & 83 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"prettier:check": "prettier --check .",
"check:spelling": "cspell --cache --no-progress '**/*'",
"check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.js",
"build:npm": "node resources/build-npm.js && node resources/build-npm-esm.js",
"build:npm": "node resources/build-npm.js && node resources/build-npm.js --esm-only",
"build:deno": "node resources/build-deno.js",
"gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist",
"gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist"
Expand All @@ -56,7 +56,6 @@
"@babel/plugin-transform-typescript": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/register": "7.15.3",
"@types/babel__core": "^7.1.16",
"@types/chai": "4.2.22",
"@types/mocha": "9.0.0",
"@types/node": "16.11.1",
Expand Down
9 changes: 0 additions & 9 deletions resources/build-npm-esm.js

This file was deleted.

17 changes: 9 additions & 8 deletions resources/build-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,31 @@ const prettierConfig = JSON.parse(
fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'),
);

const isESMOnly = process.argv.includes('--esm-only');

if (require.main === module) {
buildNPM();
}

exports.buildNPM = buildNPM;

function buildNPM({ isFullESM = false } = {}) {
const distDirectory = isFullESM ? './npmEsmDist' : './npmDist';
function buildNPM() {
const distDirectory = isESMOnly ? './npmEsmDist' : './npmDist';

fs.rmSync(distDirectory, { recursive: true, force: true });
fs.mkdirSync(distDirectory);

const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ });

const packageJSON = buildPackageJSON(srcFiles, { isFullESM });
const packageJSON = buildPackageJSON(srcFiles);

for (const filepath of srcFiles) {
const srcPath = path.join('./src', filepath);
const destPath = path.join(distDirectory, filepath);

fs.mkdirSync(path.dirname(destPath), { recursive: true });
if (filepath.endsWith('.ts')) {
if (isFullESM) {
if (isESMOnly) {
const js =
filepath === 'version.ts'
? babelTransform(getVersionFileBody(packageJSON.version), {
Expand Down Expand Up @@ -85,7 +87,7 @@ function buildNPM({ isFullESM = false } = {}) {

assert(packageJSON.types === undefined, 'Unexpected "types" in package.json');

if (isFullESM) {
if (isESMOnly) {
packageJSON.typesVersions = {
'>=4.2.0': {
'*': ['*'],
Expand Down Expand Up @@ -150,7 +152,6 @@ function buildPackageJSON(
* @type {string[]}
*/
srcFiles,
{ isFullESM = false } = {},
) {
/**
* @type {Record<string,unknown>}
Expand All @@ -163,7 +164,7 @@ function buildPackageJSON(
delete packageJSON.scripts;
delete packageJSON.devDependencies;

if (isFullESM) {
if (isESMOnly) {
delete packageJSON.module;
packageJSON.version = `${packageJSON.version}-esm`;

Expand Down Expand Up @@ -199,7 +200,7 @@ function buildPackageJSON(
packageJSON.publishConfig = { tag: publishTag };
}

if (isFullESM) {
if (isESMOnly) {
/**
* This allows imports without explicit extensions and index imports
* Like `import("graphql/language/parser")` and `import("graphql/utilities")`
Expand Down

0 comments on commit d295901

Please sign in to comment.