Compare commits
2 Commits
883f811f91
...
8ea326514b
Author | SHA1 | Date |
---|---|---|
|
8ea326514b | |
|
d5ab556f45 |
|
@ -27,20 +27,6 @@ const loaderFunction = `function loadNativeModuleTemp(module, data) {
|
||||||
return loadPath;
|
return loadPath;
|
||||||
}`;
|
}`;
|
||||||
function bundleNativeModulesPlugin() {
|
function bundleNativeModulesPlugin() {
|
||||||
const edits = [];
|
|
||||||
/*
|
|
||||||
Copied from https://github.com/sastan/rollup-plugin-define/blob/main/src/define.ts
|
|
||||||
*/
|
|
||||||
function markEdited(node, edits) {
|
|
||||||
for (const [start, end] of edits) {
|
|
||||||
if ((start <= node.start && node.start < end) ||
|
|
||||||
(start < node.end && node.end <= end)) {
|
|
||||||
return false; // Already edited
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Not edited
|
|
||||||
return edits.push([node.start, node.end]);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
name: "bundle-native-modules",
|
name: "bundle-native-modules",
|
||||||
transform(src, id, ast) {
|
transform(src, id, ast) {
|
||||||
|
@ -69,6 +55,20 @@ function bundleNativeModulesPlugin() {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const edits = [];
|
||||||
|
/*
|
||||||
|
Copied from https://github.com/sastan/rollup-plugin-define/blob/main/src/define.ts
|
||||||
|
*/
|
||||||
|
function markEdited(node, edits) {
|
||||||
|
for (const [start, end] of edits) {
|
||||||
|
if ((start <= node.start && node.start < end) ||
|
||||||
|
(start < node.end && node.end <= end)) {
|
||||||
|
return false; // Already edited
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Not edited
|
||||||
|
return edits.push([node.start, node.end]);
|
||||||
|
}
|
||||||
const findLoady = (0, ast_matcher_1.default)("require('loady')(__str_aName, __any)");
|
const findLoady = (0, ast_matcher_1.default)("require('loady')(__str_aName, __any)");
|
||||||
const loadyMatches = findLoady(ast);
|
const loadyMatches = findLoady(ast);
|
||||||
if (loadyMatches?.length) {
|
if (loadyMatches?.length) {
|
||||||
|
|
38
src/index.ts
38
src/index.ts
|
@ -28,25 +28,6 @@ type Edit = [number, number];
|
||||||
type AstNode = { start: number; end: number };
|
type AstNode = { start: number; end: number };
|
||||||
|
|
||||||
export default function bundleNativeModulesPlugin() {
|
export default function bundleNativeModulesPlugin() {
|
||||||
const edits: Edit[] = [];
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copied from https://github.com/sastan/rollup-plugin-define/blob/main/src/define.ts
|
|
||||||
*/
|
|
||||||
function markEdited(node: AstNode, edits: Edit[]): number | false {
|
|
||||||
for (const [start, end] of edits) {
|
|
||||||
if (
|
|
||||||
(start <= node.start && node.start < end) ||
|
|
||||||
(start < node.end && node.end <= end)
|
|
||||||
) {
|
|
||||||
return false; // Already edited
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not edited
|
|
||||||
return edits.push([node.start, node.end]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "bundle-native-modules",
|
name: "bundle-native-modules",
|
||||||
transform(src, id, ast: any) {
|
transform(src, id, ast: any) {
|
||||||
|
@ -81,6 +62,25 @@ export default function bundleNativeModulesPlugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const edits: Edit[] = [];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copied from https://github.com/sastan/rollup-plugin-define/blob/main/src/define.ts
|
||||||
|
*/
|
||||||
|
function markEdited(node: AstNode, edits: Edit[]): number | false {
|
||||||
|
for (const [start, end] of edits) {
|
||||||
|
if (
|
||||||
|
(start <= node.start && node.start < end) ||
|
||||||
|
(start < node.end && node.end <= end)
|
||||||
|
) {
|
||||||
|
return false; // Already edited
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not edited
|
||||||
|
return edits.push([node.start, node.end]);
|
||||||
|
}
|
||||||
|
|
||||||
const findLoady = astMatcher("require('loady')(__str_aName, __any)");
|
const findLoady = astMatcher("require('loady')(__str_aName, __any)");
|
||||||
const loadyMatches = findLoady(ast);
|
const loadyMatches = findLoady(ast);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue