forked from facebook/lexical
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into node-fork-modules
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 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
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,41 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import copy from 'rollup-plugin-copy'; | ||
|
||
function parseImportMapImportEntries() { | ||
const m = /<script type="importmap">([\s\S]+?)<\/script>/g.exec( | ||
fs.readFileSync('./esm/index.html', 'utf8'), | ||
); | ||
if (!m) { | ||
throw new Error('Could not parse importmap from esm/index.html'); | ||
} | ||
return Object.entries<string>(JSON.parse(m[1]).imports); | ||
} | ||
|
||
// Fork modules are only produced by the build script | ||
export default function viteCopyEsm() { | ||
return copy({ | ||
hook: 'writeBundle', | ||
targets: [ | ||
{dest: './build/esm/', src: './esm/*'}, | ||
{dest: './build/', src: ['./*.png', './*.ico']}, | ||
...parseImportMapImportEntries().map(([mod, fn]) => ({ | ||
dest: './build/esm/dist/', | ||
src: path.join( | ||
`../${mod.replace(/^@/, '').replace(/\//g, '-')}`, | ||
// Fork modules are only produced by build-release, which is not run | ||
// in CI, so we don't need to worry about choosing dev or prod | ||
fn, | ||
), | ||
})), | ||
], | ||
verbose: true, | ||
}); | ||
} |
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