Skip to content

Commit

Permalink
fix: replace source-map with source-map-js
Browse files Browse the repository at this point in the history
source-map-js is a js fork with applied optimisations comparable with
rust optimisation in latest source-map versions.

Staying on js allows us to bundle package and not increase install size.

As a bonus I added support for importing from lib directly so we could
avoid bundling whole package. See 7rulnik/source-map-js#13

```
du -ck dist/node
```
before: 4164 kB
after: 4140 kB
  • Loading branch information
TrySound committed Jan 18, 2022
1 parent e6b06e5 commit 80e0e74
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prettier": "2.5.1",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.59.0",
"rollup": "^2.62.0",
"semver": "^7.3.5",
"simple-git-hooks": "^2.7.0",
"sirv": "^2.0.0",
Expand Down
57 changes: 3 additions & 54 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1685,40 +1685,6 @@ Repository: git+https://github.com/css-modules/icss-utils.git
---------------------------------------

## import-cwd
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/import-cwd

> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## import-from
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/import-from

> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## inflight
License: ISC
By: Isaac Z. Schlueter
Expand Down Expand Up @@ -3338,23 +3304,6 @@ Repository: https://github.com/unshiftio/requires-port
---------------------------------------

## resolve-from
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/resolve-from

> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## resolve.exports
License: MIT
By: Luke Edwards
Expand Down Expand Up @@ -3543,10 +3492,10 @@ Repository: lukeed/sirv

---------------------------------------

## source-map
## source-map-js
License: BSD-3-Clause
By: Nick Fitzgerald, Tobias Koppers, Duncan Beevers, Stephen Crane, Ryan Seddon, Miles Elam, Mihai Bazon, Michael Ficarra, Todd Wolfson, Alexander Solovyov, Felix Gnass, Conrad Irwin, usrbincc, David Glasser, Chase Douglas, Evan Wallace, Heather Arthur, Hugh Kennedy, Simon Lydell, Jmeas Smith, Michael Z Goddard, azu, John Gozde, Adam Kirkton, Chris Montgomery, J. Ryan Stinnett, Jack Herrington, Chris Truter, Daniel Espeset, Jamie Wong, Eddy Bruël, Hawken Rives, Gilad Peleg, djchie, Gary Ye, Nicolas Lalevée
Repository: http://github.com/mozilla/source-map.git
By: Valentin 7rulnik Semirulnik, Nick Fitzgerald, Tobias Koppers, Duncan Beevers, Stephen Crane, Ryan Seddon, Miles Elam, Mihai Bazon, Michael Ficarra, Todd Wolfson, Alexander Solovyov, Felix Gnass, Conrad Irwin, usrbincc, David Glasser, Chase Douglas, Evan Wallace, Heather Arthur, Hugh Kennedy, Simon Lydell, Jmeas Smith, Michael Z Goddard, azu, John Gozde, Adam Kirkton, Chris Montgomery, J. Ryan Stinnett, Jack Herrington, Chris Truter, Daniel Espeset, Jamie Wong, Eddy Bruël, Hawken Rives, Gilad Peleg, djchie, Gary Ye, Nicolas Lalevée
Repository: 7rulnik/source-map-js

> Copyright (c) 2009-2011, Mozilla Foundation and contributors
> All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"resolve.exports": "^1.1.0",
"rollup-plugin-license": "^2.6.0",
"sirv": "^2.0.0",
"source-map": "^0.6.1",
"source-map-js": "^1.0.2",
"source-map-support": "^0.5.21",
"strip-ansi": "^6.0.1",
"terser": "^5.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import type { ResolvedConfig } from '../config'
import { buildErrorMessage } from './middlewares/error'
import type { ModuleGraph } from './moduleGraph'
import { performance } from 'perf_hooks'
import { SourceMapConsumer } from 'source-map'
import { SourceMapConsumer } from 'source-map-js/lib/source-map-consumer'
import type * as postcss from 'postcss'

export interface PluginContainerOptions {
Expand Down
6 changes: 2 additions & 4 deletions packages/vite/src/node/ssr/ssrStacktrace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RawSourceMap } from 'source-map'
import { SourceMapConsumer } from 'source-map'
import type { RawSourceMap } from 'source-map-js'
import { SourceMapConsumer } from 'source-map-js/lib/source-map-consumer'
import type { ModuleGraph } from '../server/moduleGraph'

let offset: number
Expand Down Expand Up @@ -32,8 +32,6 @@ export function ssrRewriteStacktrace(
return input
}

// In `source-map:v0.7.0+` this constructor returns a Promise...
// How can we make this block async?
const consumer = new SourceMapConsumer(
rawSourceMap as unknown as RawSourceMap
)
Expand Down
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 80e0e74

Please sign in to comment.