-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore!: publish gax-nodejs in dual format (CJS and ESM) #1679
Open
sofisl
wants to merge
59
commits into
main
Choose a base branch
from
migrateToEsm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
d65013f
working compilation
sofisl 287271b
save for now
sofisl 24b6195
save for now
sofisl 3566f28
go back to no esm
sofisl 955896c
check what is going on
sofisl 237abba
try pushing tests up
sofisl 8e57aea
Merge branch 'main' into migrateToEsm
sofisl a17f484
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] e702960
Merge branch 'migrateToEsm' of https://github.com/googleapis/gax-node…
gcf-owl-bot[bot] 57acad4
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 53d9f3f
Merge branch 'migrateToEsm' of https://github.com/googleapis/gax-node…
gcf-owl-bot[bot] 882a1d9
run 18+ tests
sofisl 1a66338
Merge branch 'migrateToEsm' of github.com:googleapis/gax-nodejs into …
sofisl 1656a87
fix broken error
sofisl 7f68430
rerun lint and fix test in tools
sofisl 200d304
skip test
sofisl 9a34cbd
fix broken linter
sofisl d27baf9
chore: update post processor
sofisl c8d0d22
migrate to node 18
sofisl 10837c3
restart tests
sofisl 28ae15b
retry
sofisl 82f62bd
rerun lint
sofisl 82ed56e
fix missing types
sofisl 520e4d8
Update package.json
sofisl 32fd81e
fix system tests
sofisl 2a0dd66
Merge branch 'migrateToEsm' of github.com:googleapis/gax-nodejs into …
sofisl 0f0c1b6
retry
sofisl be673ee
retry
sofisl c298e08
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 1aede4a
reruntests
sofisl 4c93886
Merge branch 'migrateToEsm' of github.com:googleapis/gax-nodejs into …
sofisl f1be309
chore: also export protobuf.js as esm
sofisl ed5055a
run lint and fix test
sofisl 5c212dc
retry system tests
sofisl 97ab9b9
fix path to test-application
sofisl 901b20f
retry system test
sofisl fd44396
see difference in browser-test
sofisl 7df63e0
rename assert assertion
sofisl a98c2d5
fix system test
sofisl 6f306ec
clean up RP
sofisl 14ca692
chore: clean tests
sofisl 98d9366
fix broken test and rerun lint
sofisl 76f5565
fix browser test
sofisl 048e05b
clean up extensions and use node-fetch
sofisl ccf8a34
run lint
sofisl 896679f
fix node-fetch
sofisl f4926a7
retry dynamically importing node-fetch
sofisl 2d5e67f
chore: update how we import node-fetch
sofisl 2a2bce1
fix babel to compile dynamic imports correctly
sofisl 00e2472
run lint
sofisl f07c571
fix path of importing node-fetch dynamically
sofisl a1b539e
retry using dynamic import
sofisl fdb98ae
try importing default version of node-fetch
sofisl f78fcd9
attempt to get browser tests to work with separate browser entrypoint…
sofisl dc5c20d
get system tests to work
sofisl 7d4f877
add node 22 tests
sofisl 8ebae3c
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 7c9dbe7
chore: remove `allowSyntheticDefaultImports`
d-goog a8bca8a
fix: protobuf.js types
d-goog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,19 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-typescript", | ||
"@babel/env" | ||
], | ||
"plugins": [ | ||
[ | ||
"replace-import-extension", | ||
{ | ||
"extMapping": { | ||
".js": ".cjs" | ||
} | ||
} | ||
], | ||
"./node_modules/gapic-tools/build/src/replaceESMMockingLib.js", | ||
"./node_modules/gapic-tools/build/src/replaceImportMetaUrl.js", | ||
"./node_modules/gapic-tools/build/src/toggleESMFlagVariable.js" | ||
] | ||
} |
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 |
---|---|---|
|
@@ -5,3 +5,6 @@ build/ | |
docs/ | ||
protos/ | ||
samples/generated/ | ||
**/*.d.ts | ||
*.d.ts | ||
**/**.d.ts |
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 |
---|---|---|
|
@@ -23,3 +23,6 @@ dist/ | |
*.tgz | ||
**/*.tgz | ||
test/showcase-echo-client/protos/protos.* | ||
**/*.d.ts | ||
*.d.ts | ||
**/**.d.ts |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function getAllFiles(dirPath, arrayOfFiles) { | ||
const files = fs.readdirSync(dirPath); | ||
|
||
arrayOfFiles = arrayOfFiles || []; | ||
|
||
files.forEach(file => { | ||
if (fs.statSync(path.join(dirPath, file)).isDirectory()) { | ||
arrayOfFiles = getAllFiles(path.join(dirPath, file), arrayOfFiles); | ||
} else { | ||
arrayOfFiles.push(path.join(dirPath, file)); | ||
} | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
function getAllFullFilePaths(dirname, filenames) { | ||
// const files = fs.readdirSync(dirPath); | ||
|
||
const arrayOfFiles = []; | ||
|
||
filenames.forEach(file => { | ||
arrayOfFiles.push(path.join(dirname, file)); | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
function main(directoryOrFilenames) { | ||
let fileNames; | ||
if ( | ||
fs.statSync(path.join(__dirname, directoryOrFilenames[0])).isDirectory() | ||
) { | ||
fileNames = getAllFiles(directoryOrFilenames[0]); | ||
} else { | ||
fileNames = getAllFullFilePaths(__dirname, directoryOrFilenames); | ||
} | ||
for (const file of fileNames) { | ||
let contents = fs.readFileSync(file, 'utf8'); | ||
if (contents.includes('proxyquire')) { | ||
contents = contents.replace(/\.js'/g, ".cjs'"); | ||
fs.writeFileSync(file, contents); | ||
} | ||
} | ||
} | ||
|
||
main(process.argv.slice(2)); |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add a package.json with
type: commonjs
? According to spec:Additionally reading/examples for this pattern:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for changing the extension in proxyquire calls, so it wouldn't be affected by a package.json, although I see your larger point that we wouldn't even have to do that if we didn't rename the files at all. It seems slightly cleaner/safer to me to have the .cjs and .js distinguishing the files, easier to see at a glance what's going on, but that's just my perspective!