-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: add initial support of Deno build (#2636)
Motivation #2566
- Loading branch information
1 parent
75e0ec7
commit eb1cfe2
Showing
12 changed files
with
255 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"plugins": [ | ||
"@babel/plugin-transform-flow-strip-types", | ||
["./resources/add-extension-to-import-paths", { "extension": "mjs" }], | ||
"./resources/inline-invariant" | ||
], | ||
"overrides": [ | ||
{ | ||
"include": "src/error/GraphQLError.js", | ||
"plugins": [["@babel/plugin-transform-classes", { "loose": false }]] | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
.eslintcache | ||
node_modules | ||
coverage | ||
dist | ||
npmDist | ||
denoDist | ||
benchmarkDist | ||
npm | ||
deno |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @noflow | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const babel = require('@babel/core'); | ||
|
||
const { rmdirRecursive, readdirRecursive, showDirStats } = require('./utils'); | ||
|
||
if (require.main === module) { | ||
rmdirRecursive('./denoDist'); | ||
fs.mkdirSync('./denoDist'); | ||
|
||
const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ }); | ||
for (const filepath of srcFiles) { | ||
const srcPath = path.join('./src', filepath); | ||
const destPath = path.join('./denoDist', filepath); | ||
|
||
fs.mkdirSync(path.dirname(destPath), { recursive: true }); | ||
if (filepath.endsWith('.js')) { | ||
const options = { babelrc: false, configFile: './.babelrc-deno.json' }; | ||
const output = babel.transformFileSync(srcPath, options).code + '\n'; | ||
fs.writeFileSync(destPath, output); | ||
} else if (filepath.endsWith('.d.ts')) { | ||
fs.copyFileSync(srcPath, destPath); | ||
} | ||
} | ||
|
||
fs.copyFileSync('./LICENSE', './denoDist/LICENSE'); | ||
fs.copyFileSync('./README.md', './denoDist/README.md'); | ||
|
||
showDirStats('./denoDist'); | ||
} |
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,77 @@ | ||
// @noflow | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
|
||
const babel = require('@babel/core'); | ||
|
||
const { rmdirRecursive, readdirRecursive, showDirStats } = require('./utils'); | ||
|
||
if (require.main === module) { | ||
rmdirRecursive('./npmDist'); | ||
fs.mkdirSync('./npmDist'); | ||
|
||
const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ }); | ||
for (const filepath of srcFiles) { | ||
const srcPath = path.join('./src', filepath); | ||
const destPath = path.join('./npmDist', filepath); | ||
|
||
fs.mkdirSync(path.dirname(destPath), { recursive: true }); | ||
if (filepath.endsWith('.js')) { | ||
fs.copyFileSync(srcPath, destPath + '.flow'); | ||
|
||
const cjs = babelBuild(srcPath, { envName: 'cjs' }); | ||
fs.writeFileSync(destPath, cjs); | ||
|
||
const mjs = babelBuild(srcPath, { envName: 'mjs' }); | ||
fs.writeFileSync(destPath.replace(/\.js$/, '.mjs'), mjs); | ||
} else if (filepath.endsWith('.d.ts')) { | ||
fs.copyFileSync(srcPath, destPath); | ||
} | ||
} | ||
|
||
fs.copyFileSync('./LICENSE', './npmDist/LICENSE'); | ||
fs.copyFileSync('./README.md', './npmDist/README.md'); | ||
|
||
// Should be done as the last step so only valid packages can be published | ||
const packageJSON = buildPackageJSON(); | ||
fs.writeFileSync( | ||
'./npmDist/package.json', | ||
JSON.stringify(packageJSON, null, 2), | ||
); | ||
|
||
showDirStats('./npmDist'); | ||
} | ||
|
||
function babelBuild(srcPath, options) { | ||
return babel.transformFileSync(srcPath, options).code + '\n'; | ||
} | ||
|
||
function buildPackageJSON() { | ||
const packageJSON = require('../package.json'); | ||
delete packageJSON.private; | ||
delete packageJSON.scripts; | ||
delete packageJSON.devDependencies; | ||
|
||
packageJSON.engines = packageJSON.engines_on_npm; | ||
delete packageJSON.engines_on_npm; | ||
|
||
const versionJS = require('../npmDist/version.js'); | ||
assert( | ||
versionJS.version === packageJSON.version, | ||
'Version in package.json and version.js should match', | ||
); | ||
|
||
if (versionJS.preReleaseTag != null) { | ||
const [tag] = versionJS.preReleaseTag.split('.'); | ||
assert(['alpha', 'beta', 'rc'].includes(tag), `"${tag}" tag is supported.`); | ||
|
||
assert(!packageJSON.publishConfig, 'Can not override "publishConfig".'); | ||
packageJSON.publishConfig = { tag: tag || 'latest' }; | ||
} | ||
|
||
return packageJSON; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.