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

chore: remove legacy dist files (BREAKING CHANGE) #3585

Merged
merged 2 commits into from
Jun 27, 2023
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
48 changes: 0 additions & 48 deletions scripts/rollup/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/* eslint-env node */

const { readFileSync } = require('node:fs');
const { writeFile, mkdir } = require('node:fs/promises');
const path = require('node:path');
const MagicString = require('magic-string');
const { rollup } = require('rollup');
Expand Down Expand Up @@ -119,52 +118,6 @@ function injectInlineRenderer() {
};
}

// TODO [#3445]: this purely exists for backwards compatibility, to avoid breaking code like this:
//
// require('@lwc/synthetic-shadow/dist/synthetic-shadow.js')
// require('@lwc/engine-server/dist/engine-server.js')
// require('@lwc/compiler/dist/commonjs/transformers/transformer')
//
// Feel free to delete this entire plugin once we can safely release this breaking change.
function backwardsCompatDistPlugin() {
const packageNamesToExtraDistFiles = {
'@lwc/compiler': {
'index.cjs.js': 'dist/commonjs/transformers/transformer.js',
},
'@lwc/engine-dom': {
'index.js': 'dist/engine-dom.js',
},
'@lwc/engine-server': {
'index.js': 'dist/engine-server.js',
},
'@lwc/synthetic-shadow': {
'index.js': 'dist/synthetic-shadow.js',
},
'@lwc/wire-service': {
'index.js': 'dist/wire-service.js',
},
};

return {
id: 'backwards-compat-dist',
async writeBundle(options, bundle) {
const extraDistFiles = packageNamesToExtraDistFiles[packageName];
if (extraDistFiles) {
for (const [id, extraDistFile] of Object.entries(extraDistFiles)) {
const descriptor = bundle[id];
if (descriptor) {
// Write additional dist/ file as a side effect
const fullFilename = path.join(packageRoot, extraDistFile);
await mkdir(path.dirname(fullFilename), { recursive: true });
await writeFile(fullFilename, descriptor.code, 'utf-8');
}
}
}
return null;
},
};
}

module.exports = {
input: path.resolve(packageRoot, './src/index.ts'),

Expand Down Expand Up @@ -198,7 +151,6 @@ module.exports = {
include: [/\/parse5\//],
}),
...sharedPlugins(),
backwardsCompatDistPlugin(),
injectInlineRenderer(),
],

Expand Down