@@ -46,10 +46,10 @@ const loader1 = '@vercel/webpack-asset-relocator-loader'
4646const outputAssetBase = 'native_modules'
4747const NativeExt = '.native.cjs'
4848const InteropExt = '.interop.mjs'
49- // https://github.com/vitejs/vite/blob/v5.3.1/packages/vite/src/node/plugins/index.ts#L55
50- const bareImportRE = / ^ (? ! [ a - z A - Z ] : ) [ \w @ ] (? ! .* : \/ \/ ) /
5149// `nativesMap` is placed in the global scope and can be effective for multiple builds.
5250const nativesMap = new Map < string , ResolvedNativeRecord >
51+ // https://github.com/npm/validate-npm-package-name/blob/v5.0.1/lib/index.js#L4
52+ const scopedPackagePattern = / ^ (? ! [ a - z A - Z ] : ) [ \w @ ] (? ! .* : \/ \/ ) /
5353
5454export default function native ( options : NativeOptions ) : Plugin {
5555 const assetsDir = options . assetsDir ??= 'node_natives'
@@ -75,13 +75,13 @@ export default function native(options: NativeOptions): Plugin {
7575
7676 const withDistAssetBase = ( p : string ) => ( assetsDir && p ) ? `${ assetsDir } /${ p } ` : p
7777 const alias : Alias = {
78- find : / ( .* ) / ,
78+ find : / ^ (? ! (?: \/ ? @ v i t e \/ | \. ) ) ( .* ) / ,
7979 // Keep `customResolver` receive original source.
8080 // @see https://github.com/rollup/plugins/blob/alias-v5.1.0/packages/alias/src/index.ts#L92
8181 replacement : '$1' ,
8282 async customResolver ( source , importer ) {
8383 if ( ! importer ) return
84- if ( ! bareImportRE . test ( source ) ) return
84+ if ( ! scopedPackagePattern . test ( source ) ) return
8585
8686 if ( ! nativeRecord . has ( source ) ) {
8787 // Dynamic deep detection.
0 commit comments