Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

❄️: properly exclude modules in freezer #1645

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lively.freezer/src/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export default class LivelyRollup {
*/
async transform (source, id) {
const originalSource = source;
if (id.startsWith('\0') || id.endsWith('.json')) {
if (id.startsWith('\0') || id.endsWith('.json') || this.excludedModules.find(m => id.startsWith(m))) {
return source;
}
// We use the string 'projectAsset' there in regular code to enable correct reconciliation.
Expand Down Expand Up @@ -467,6 +467,7 @@ export default class LivelyRollup {
if (!mapping[id] && this.globalMap[id]) {
console.warn(`[freezer] No mapping for "${id}" provided by package "${importingPackage.name}". Guessing "${this.globalMap[id]}" based on past resolutions. Please consider adding a map entry to this package config in oder to make the package definition sound and work independently of the current setup!`); // eslint-disable-line no-console
}
if (this.excludedModules.includes(id)) return id;
let remapped = mapping[id] || this.globalMap[id];
const ctx = this.asBrowserModule ? '~node' : 'node';
if (remapped[ctx]) remapped = remapped[ctx];
Expand All @@ -490,7 +491,7 @@ export default class LivelyRollup {
// results since we are not taking into account in package.json

absolutePath = this.resolver.resolveModuleId(id, importer, this.getResolutionContext());
if (this.belongsToExcludedPackage(absolutePath)) return null;
if (this.belongsToExcludedPackage(absolutePath)) return id;
return this.resolved[resolutionId(id, importer)] = absolutePath;
}

Expand Down Expand Up @@ -529,7 +530,7 @@ export default class LivelyRollup {
* @returns { string } The source code.
*/
async load (id) {
if (this.excludedModules.includes(id)) {
if (this.excludedModules.find(m => id.startsWith(m))) {
if (id === 'lively.ast') {
return `
let nodes = {}, query = {}, transform = {}, BaseVisitor = Object;
Expand All @@ -540,6 +541,7 @@ export default class LivelyRollup {
let scripting = {};
export { scripting };`;
}
return '';
}

if (id === ROOT_ID) {
Expand Down
Loading