-
Notifications
You must be signed in to change notification settings - Fork 45
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
Include src/ directory in npm package to fix source map loading #23
Merged
Conversation
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
The compiled JavaScript we ship includes embedded source maps because we enable "inlineSourceMap" in tsconfig.json. Those source maps reference the original TypeScript files by name instead of embedding their contents because we don't set "inlineSources". However, we currently don't include those TypeScript files in the package we distribute. We only include the compiled files from build/. This causes a warning when source-map-loader, run from a downstream package, tries to load maps: WARNING in ./node_modules/plausible-tracker/build/module/index.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map from '.../node_modules/plausible-tracker/src/index.ts' file: Error: ENOENT: no such file or directory, open '.../node_modules/plausible-tracker/src/index.ts' @ ./src/analytics/plausible.ts 3:0-42 11:29-38 @ ./src/index.tsx 8:0-55 13:0-14 To fix the issue, add src/ to "files" in package.json. Alternatively, we could have set "inlineSources" to true in tsconfig.json, but that results in the TypeScript being encoded as Base64, which is less efficient than just shipping the files directly.
tchebb
added a commit
to tchebb/wayland-explorer
that referenced
this pull request
Jan 25, 2022
This makes several significant changes to our dependencies: - react-scripts (i.e. create-react-app) is now v5 (from v4) - tailwindcss is now v3 (from a variant of v2 targeting postcss v7) - postcss is now v8 (from v7) - autoprefixer is now v10 (from v9) - craco is no longer used because react-scripts v5 natively supports tailwindcss The postcss and autoprefixer upgrades required no changes on our end, as they're used only through tailwindcss. The craco removal required minor changes to package.json to go back to invoking react-scripts directly. The react-scripts upgrade didn't require any changes apart from the other dependency upgrades. However, it did introduce a couple new harmless warnings to the build. The first is a pair of "DeprecationWarning" messages from webpack-dev-server for which a fix has already been submitted upstream to create-react-app[1]. The second is three "Failed to parse source map" messages from source-map-loader. These are due to a bug in plausible-tracker for which I've submitted a fix[2]. The tailwindcss upgrade was the most invasive and required a number of changes to our CSS and config. I fully followed the upgrade guide[3] and tested as much functionality as I could. As far as I can tell, the site behaves and appears identical to how it did before. [1] facebook/create-react-app#11862 [2] plausible/plausible-tracker#23 [3] https://tailwindcss.com/docs/upgrade-guide
Makes sense, thank you! |
Just published v0.3.5 on NPM. Give it a try |
tchebb
added a commit
to tchebb/wayland-explorer
that referenced
this pull request
Jan 26, 2022
This makes several significant changes to our dependencies: - react-scripts (i.e. create-react-app) is now v5 (from v4) - tailwindcss is now v3 (from a variant of v2 targeting postcss v7) - postcss is now v8 (from v7) - autoprefixer is now v10 (from v9) - craco is no longer used because react-scripts v5 natively supports tailwindcss The postcss and autoprefixer upgrades required no changes on our end, as they're used only through tailwindcss. The craco removal required minor changes to package.json to go back to invoking react-scripts directly. The react-scripts upgrade didn't require any changes apart from the other dependency upgrades. However, it did introduce a couple new harmless warnings to the build. The first is a pair of "DeprecationWarning" messages from webpack-dev-server for which a fix has already been submitted upstream to create-react-app[1]. The second is three "Failed to parse source map" messages from source-map-loader. These are due to a bug in plausible-tracker for which I've submitted a fix[2]. The tailwindcss upgrade was the most invasive and required a number of changes to our CSS and config. I fully followed the upgrade guide[3] and tested as much functionality as I could. As far as I can tell, the site behaves and appears identical to how it did before. [1] facebook/create-react-app#11862 [2] plausible/plausible-tracker#23 [3] https://tailwindcss.com/docs/upgrade-guide
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
The compiled JavaScript we ship includes embedded source maps because we enable
"inlineSourceMap"
intsconfig.json
. Those source maps reference the original TypeScript files by name instead of embedding their contents because we don't set"inlineSources"
.However, we currently don't include those TypeScript files in the package we distribute. We only include the compiled files from
build/
. This causes a warning when source-map-loader, run from a downstream package, tries to load maps:To fix the issue, add
src/
to"files"
inpackage.json
. Alternatively, we could have set"inlineSources"
totrue
intsconfig.json
, but that results in the TypeScript being encoded as Base64, which is less efficient than just shipping the files directly.Related Issue
#22
Types of changes
Checklist: