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: Move source files into src/ and emit to lib/ with TypeScript #5568
Conversation
@mathiasbynens @TimvdLippe would love your thoughts on this please. The goal here is to have TypeScript not only type-check but emit our JavaScript, in preparation for us to start replacing files with This PR is more a starting point & one solution that works rather than definitely the best one - I think there's a few ways we could do this and I'm happy to chat about it. Can always jump on a call :) |
CI is failing for a legitimate reason: However for TypeScript to run it needs
EDIT: thinking about it, this isn't a problem for an end user installing the package because |
GitHub search is not really working for me, but this search seemed the most sane: https://github.com/search?q=%22puppeteer%2Flib%22&type=Code That search isn't immediately showing any actual usage of direct files in puppeteer. Emitting with I have no knowledge about the install scripts and how they all tie together. I will leave that to @mathiasbynens |
We can prevent the breaking change in this case, so let's do it. I like Tim's suggestion of moving |
Great thinking - I'll update this PR to move |
This updates our `tsconfig.json` so it emits our JavaScript files as well as type checking them. We compile into `./lib` which we then ship in our npm package. The source code has moved from `./lib` into `./src`. Because the `src/` directory is exclusively JS files, this change is a no-op in terms of code functionality but is the first step towards being able to replace `src/X.js` with `src/X.ts` in a way that allows us to migrate incrementally. The `lib` directory is gitignored, and the `src` directory is npmignored. On `npm publish` we will now run `npm run tsc` in order to generate the outputted code.
f9ad309
to
ba39aa8
Compare
This updates our
tsconfig.json
so it emits our JavaScript files aswell as type checking them. We compile into
./out
which we then shipin our npm package.
Because the
lib/
directory is exclusively JS files, this change is ano-op in terms of code functionality but is the first step towards being
able to replace
lib/X.js
withlib/X.ts
in a way that allows us tomigrate incrementally.
The
out
directory is gitignored, and thelib
directory isnpmignored. On
npm publish
we will now runnpm run tsc
in order togenerate the outputted code.
Any imports that import from
lib/X
now import fromout/X
.BREAKING CHANGE: if users are importing Puppeteer modules, e.g.:
This path has now changed to:
** EDIT ** the above is outdated; the below is what we now do:
This updates our
tsconfig.json
so it emits our JavaScript files aswell as type checking them. We compile into
./lib
which we then shipin our npm package. The source code has moved from
./lib
into./src
.Because the
src/
directory is exclusively JS files, this change is ano-op in terms of code functionality but is the first step towards being
able to replace
src/X.js
withsrc/X.ts
in a way that allows us tomigrate incrementally.
The
lib
directory is gitignored, and thesrc
directory isnpmignored. On
npm publish
we will now runnpm run tsc
in order togenerate the outputted code.