@granite-js/mpack 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/bundler/plugins/resolvePlugin/alias/setupAliasResolver.js +5 -1
- package/dist/metro/build.js +1 -1
- package/dist/metro/enhancedResolver.d.ts +4 -5
- package/dist/metro/enhancedResolver.js +3 -3
- package/dist/metro/getMetroConfig.js +6 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @granite-js/mpack
|
|
2
2
|
|
|
3
|
+
## 0.1.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9bf8b50: expose resolveRequest option
|
|
8
|
+
- e957833: expose `resolver.resolverMainFields` and `resolver.unstable_conditionNames` options
|
|
9
|
+
- Updated dependencies [9bf8b50]
|
|
10
|
+
- Updated dependencies [e957833]
|
|
11
|
+
- @granite-js/plugin-core@0.1.31
|
|
12
|
+
- @granite-js/devtools-frontend@0.1.31
|
|
13
|
+
- @granite-js/utils@0.1.31
|
|
14
|
+
|
|
15
|
+
## 0.1.30
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9e9ea71: escape `from` string of alias config when creating RegExp
|
|
20
|
+
- @granite-js/devtools-frontend@0.1.30
|
|
21
|
+
- @granite-js/plugin-core@0.1.30
|
|
22
|
+
- @granite-js/utils@0.1.30
|
|
23
|
+
|
|
3
24
|
## 0.1.29
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -83,7 +83,8 @@ function setupAliasResolver(build, aliasConfig) {
|
|
|
83
83
|
}
|
|
84
84
|
function resolveAliasConfig(build, aliasConfig) {
|
|
85
85
|
const { from, to, exact } = aliasConfig;
|
|
86
|
-
const
|
|
86
|
+
const escapedFrom = escapeRegExpString(from);
|
|
87
|
+
const filter = new RegExp(exact ? `^${escapedFrom}$` : `^${escapedFrom}(?:$|/)`);
|
|
87
88
|
const resolver = (0, import_resolveHelpers.createNonRecursiveResolver)(build);
|
|
88
89
|
const aliasResolver = (boundArgs, path2, options) => {
|
|
89
90
|
const result = resolver({ ...boundArgs, path: path2 }, options);
|
|
@@ -102,6 +103,9 @@ function resolveAliasConfig(build, aliasConfig) {
|
|
|
102
103
|
};
|
|
103
104
|
return { filter, resolveAlias };
|
|
104
105
|
}
|
|
106
|
+
function escapeRegExpString(str) {
|
|
107
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
|
108
|
+
}
|
|
105
109
|
function normalizeResolveResult(result) {
|
|
106
110
|
if (typeof result === "string") {
|
|
107
111
|
return { path: (0, import_esbuildUtils.normalizePath)(result), options: void 0 };
|
package/dist/metro/build.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
preferNativePlatform?: boolean;
|
|
1
|
+
import type { MetroResolutionContext } from '@granite-js/plugin-core';
|
|
2
|
+
interface CreateResolverOptions {
|
|
3
|
+
conditionNames?: string[];
|
|
5
4
|
}
|
|
6
|
-
export declare function createResolver(rootPath: string): (context:
|
|
5
|
+
export declare function createResolver(rootPath: string, options?: CreateResolverOptions): (context: MetroResolutionContext, request: string, platform: string | null) => any;
|
|
7
6
|
export {};
|
|
@@ -51,7 +51,7 @@ const SUPPORTED_BUILTIN_FALLBACKS = {
|
|
|
51
51
|
};
|
|
52
52
|
const builtinModules = new Set(import_module.default.builtinModules);
|
|
53
53
|
const resolvers = /* @__PURE__ */ new Map();
|
|
54
|
-
function createResolver(rootPath) {
|
|
54
|
+
function createResolver(rootPath, options) {
|
|
55
55
|
function createResolverImpl(context, platform, rootPath2) {
|
|
56
56
|
const baseExtensions = context.sourceExts.map((extension) => `.${extension}`);
|
|
57
57
|
let finalExtensions = [...baseExtensions];
|
|
@@ -63,9 +63,9 @@ function createResolver(rootPath) {
|
|
|
63
63
|
}
|
|
64
64
|
const resolver = import_enhanced_resolve.default.create.sync({
|
|
65
65
|
extensions: finalExtensions,
|
|
66
|
-
mainFields:
|
|
66
|
+
mainFields: context.mainFields,
|
|
67
|
+
conditionNames: options?.conditionNames ?? [...import_constants.RESOLVER_EXPORTS_MAP_CONDITIONS, "require", "node", "default"],
|
|
67
68
|
mainFiles: ["index"],
|
|
68
|
-
conditionNames: [...import_constants.RESOLVER_EXPORTS_MAP_CONDITIONS, "require", "node", "default"],
|
|
69
69
|
modules: ["node_modules", import_path.default.join(rootPath2, "src")]
|
|
70
70
|
});
|
|
71
71
|
function resolve(context2, request) {
|
|
@@ -63,6 +63,9 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
|
|
|
63
63
|
const reactNativePath = import_path.default.dirname(resolveFromRoot("react-native/package.json", rootPath));
|
|
64
64
|
const resolvedRootPath = await (0, import_getMonorepoRoot.getMonorepoRoot)(rootPath);
|
|
65
65
|
const packageRootPath = await (0, import_utils.getPackageRoot)();
|
|
66
|
+
const resolveRequest = additionalConfig?.resolver?.resolveRequest ?? (0, import_enhancedResolver.createResolver)(rootPath, {
|
|
67
|
+
conditionNames: additionalConfig?.resolver?.conditionNames
|
|
68
|
+
});
|
|
66
69
|
return (0, import_loadConfig.mergeConfig)(defaultConfig, {
|
|
67
70
|
projectRoot: additionalConfig?.projectRoot || rootPath,
|
|
68
71
|
watchFolders: [resolvedRootPath, packageRootPath, ...additionalConfig?.watchFolders || []],
|
|
@@ -94,7 +97,7 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
|
|
|
94
97
|
// metro
|
|
95
98
|
platforms: ["android", "ios"],
|
|
96
99
|
useWatchman: false,
|
|
97
|
-
resolveRequest
|
|
100
|
+
resolveRequest,
|
|
98
101
|
// metro-file-map
|
|
99
102
|
sourceExts: [...import_constants.SOURCE_EXTENSIONS.map((extension) => extension.replace(/^\.?/, "")), "cjs", "mjs"],
|
|
100
103
|
blockList: (0, import_exclusionList.default)(
|
|
@@ -102,7 +105,8 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
|
|
|
102
105
|
),
|
|
103
106
|
nodeModulesPaths: additionalConfig?.resolver?.nodeModulesPaths || [],
|
|
104
107
|
extraNodeModules: additionalConfig?.resolver?.extraNodeModules || {},
|
|
105
|
-
disableHierarchicalLookup: additionalConfig?.resolver?.disableHierarchicalLookup
|
|
108
|
+
disableHierarchicalLookup: additionalConfig?.resolver?.disableHierarchicalLookup,
|
|
109
|
+
resolverMainFields: additionalConfig?.resolver?.resolverMainFields ?? import_constants.RESOLVER_MAIN_FIELDS
|
|
106
110
|
},
|
|
107
111
|
serializer: {
|
|
108
112
|
getModulesRunBeforeMainModule: () => [resolveFromRoot("react-native/Libraries/Core/InitializeCore", rootPath)],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/mpack",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "A bundler for Granite apps",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"@babel/traverse": "^7.14.0",
|
|
90
90
|
"@babel/types": "^7.0.0",
|
|
91
91
|
"@fastify/static": "7.0.1",
|
|
92
|
-
"@granite-js/devtools-frontend": "0.1.
|
|
93
|
-
"@granite-js/plugin-core": "0.1.
|
|
94
|
-
"@granite-js/utils": "0.1.
|
|
92
|
+
"@granite-js/devtools-frontend": "0.1.31",
|
|
93
|
+
"@granite-js/plugin-core": "0.1.31",
|
|
94
|
+
"@granite-js/utils": "0.1.31",
|
|
95
95
|
"@inquirer/prompts": "^7.2.3",
|
|
96
96
|
"@react-native-community/cli-plugin-metro": "11.3.7",
|
|
97
97
|
"@react-native-community/cli-server-api": "11.3.7",
|